Skip to content

Commit

Permalink
AV-220211 check listener protocol at start of validation
Browse files Browse the repository at this point in the history
  • Loading branch information
arihantg committed Oct 15, 2024
1 parent 100e36d commit b94c089
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions ako-gateway-api/k8s/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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).
Expand Down

0 comments on commit b94c089

Please sign in to comment.