diff --git a/ako-gateway-api/k8s/validator.go b/ako-gateway-api/k8s/validator.go index 33ba6bfe0..72f7014c1 100644 --- a/ako-gateway-api/k8s/validator.go +++ b/ako-gateway-api/k8s/validator.go @@ -174,6 +174,19 @@ func isValidListener(key string, gateway *gatewayv1.Gateway, gatewayStatus *gate Status(metav1.ConditionFalse). ObservedGeneration(gateway.ObjectMeta.Generation) + // protocol validation + if listener.Protocol != gatewayv1.HTTPProtocolType && + listener.Protocol != gatewayv1.HTTPSProtocolType { + utils.AviLog.Errorf("key: %s, msg: protocol is not supported for listener %s", key, listener.Name) + defaultCondition. + Reason(string(gatewayv1.ListenerReasonUnsupportedProtocol)). + Message("Unsupported protocol"). + SetIn(&gatewayStatus.Listeners[index].Conditions) + programmedCondition.SetIn(&gatewayStatus.Listeners[index].Conditions) + gatewayStatus.Listeners[index].SupportedKinds = akogatewayapilib.SupportedKinds[gatewayv1.HTTPSProtocolType] + return false + } + // hostname should not overlap with hostname of an existing gateway gatewayNsList, err := akogatewayapilib.AKOControlConfig().GatewayApiInformers().GatewayInformer.Lister().Gateways(gateway.Namespace).List(labels.Set(nil).AsSelector()) if err != nil { @@ -208,19 +221,6 @@ func isValidListener(key string, gateway *gatewayv1.Gateway, gatewayStatus *gate } } - // protocol validation - if listener.Protocol != gatewayv1.HTTPProtocolType && - listener.Protocol != gatewayv1.HTTPSProtocolType { - utils.AviLog.Errorf("key: %s, msg: protocol is not supported for listener %s", key, listener.Name) - defaultCondition. - Reason(string(gatewayv1.ListenerReasonUnsupportedProtocol)). - Message("Unsupported protocol"). - SetIn(&gatewayStatus.Listeners[index].Conditions) - programmedCondition.SetIn(&gatewayStatus.Listeners[index].Conditions) - gatewayStatus.Listeners[index].SupportedKinds = akogatewayapilib.SupportedKinds[gatewayv1.HTTPSProtocolType] - return false - } - resolvedRefCondition := akogatewayapistatus.NewCondition(). Type(string(gatewayv1.ListenerConditionResolvedRefs)). Status(metav1.ConditionFalse).