Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gatewayapi): check for Gateway listener detached #3956

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,28 @@ func validateListeners(listeners []gatewayapi.Listener) ([]gatewayapi.Listener,
portHostnames := map[gatewayapi.PortNumber]gatewayapi.Hostname{}
portProtocols := map[gatewayapi.PortNumber]gatewayapi.ProtocolType{}

appendDetachedCondition := func(
listener gatewayapi.SectionName,
reason gatewayapi.ListenerConditionReason,
message string,
) {
listenerConditions[listener] = append(
listenerConditions[listener],
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",
},
)
}

appendConflictedCondition := func(
listener gatewayapi.SectionName,
reason gatewayapi.ListenerConditionReason,
Expand All @@ -46,6 +68,23 @@ func validateListeners(listeners []gatewayapi.Listener) ([]gatewayapi.Listener,
}

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

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

if hn := l.Hostname; hn != nil {
if otherHn := portHostnames[l.Port]; otherHn == *hn {
appendConflictedCondition(
Expand Down Expand Up @@ -154,9 +193,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