Skip to content

Commit

Permalink
feat(gatewayapi): check for listener detached
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Beaumont <mjboamail@gmail.com>
  • Loading branch information
michaelbeaumont committed Mar 1, 2022
1 parent 8c8ab54 commit 7870766
Showing 1 changed file with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,36 @@ func (r *GatewayReconciler) gapiToKumaGateway(
portHostnames := map[gatewayapi.PortNumber]gatewayapi.Hostname{}
portProtocols := map[gatewayapi.PortNumber]gatewayapi.ProtocolType{}
for _, l := range gateway.Spec.Listeners {
setDetached := func(reason gatewayapi.ListenerConditionReason, message string) {
listenerConditions[l.Name] = append(listenerConditions[l.Name],
kube_meta.Condition{
Type: string(gatewayapi.ListenerConditionDetached),
Status: kube_meta.ConditionTrue,
Reason: string(reason),
Message: message,
},
kube_meta.Condition{
Type: string(gatewayapi.ListenerConditionReady),
Status: kube_meta.ConditionFalse,
Reason: string(gatewayapi.ListenerReasonInvalid),
Message: "detached",
},
)
}

switch l.Protocol {
case gatewayapi.HTTPProtocolType:
case gatewayapi.HTTPSProtocolType:
// TODO HTTPS https://github.com/kumahq/kuma/issues/3679
fallthrough
default:
setDetached(gatewayapi.ListenerReasonUnsupportedProtocol, fmt.Sprintf("unsupported protocol %s", l.Protocol))
continue
}

// TODO ListenerReasonUnsupportedAddress and ListenerReasonPortUnavailable
// need more information from Envoy Gateway

setConflicted := func(reason gatewayapi.ListenerConditionReason, message string) {
listenerConditions[l.Name] = append(listenerConditions[l.Name],
kube_meta.Condition{
Expand Down Expand Up @@ -139,9 +169,14 @@ func (r *GatewayReconciler) gapiToKumaGateway(
}
}

// We've already cleared this listener of conflicts
// We've already cleared this listener of conflicts and being detached
listenerConditions[l.Name] = append(
listenerConditions[l.Name],
kube_meta.Condition{
Type: string(gatewayapi.ListenerConditionDetached),
Status: kube_meta.ConditionFalse,
Reason: string(gatewayapi.ListenerReasonAttached),
},
kube_meta.Condition{
Type: string(gatewayapi.ListenerConditionConflicted),
Status: kube_meta.ConditionFalse,
Expand Down

0 comments on commit 7870766

Please sign in to comment.