@@ -148,23 +148,25 @@ func (g *Cloud) EnsureLoadBalancer(ctx context.Context, clusterName string, svc
148148 // Services with multiples protocols are not supported by this controller, warn the users and sets
149149 // the corresponding Service Status Condition.
150150 // https://github.com/kubernetes/enhancements/tree/master/keps/sig-network/1435-mixed-protocol-lb
151- if err := checkMixedProtocol (svc .Spec .Ports ); err != nil {
152- if hasLoadBalancerPortsError (svc ) {
151+ if ! g .AlphaFeatureGate .Enabled (AlphaFeatureMultiProtocolLB ) {
152+ if err := checkMixedProtocol (svc .Spec .Ports ); err != nil {
153+ if hasLoadBalancerPortsError (svc ) {
154+ return nil , err
155+ }
156+ klog .Warningf ("Ignoring service %s/%s using different ports protocols" , svc .Namespace , svc .Name )
157+ g .eventRecorder .Event (svc , v1 .EventTypeWarning , v1 .LoadBalancerPortsErrorReason , "LoadBalancers with multiple protocols are not supported." )
158+ svcApplyStatus := corev1apply .ServiceStatus ().WithConditions (
159+ metav1apply .Condition ().
160+ WithType (v1 .LoadBalancerPortsError ).
161+ WithStatus (metav1 .ConditionTrue ).
162+ WithReason (v1 .LoadBalancerPortsErrorReason ).
163+ WithMessage ("LoadBalancer with multiple protocols are not supported" ))
164+ svcApply := corev1apply .Service (svc .Name , svc .Namespace ).WithStatus (svcApplyStatus )
165+ if _ , errApply := g .client .CoreV1 ().Services (svc .Namespace ).ApplyStatus (ctx , svcApply , metav1.ApplyOptions {FieldManager : "gce-cloud-controller" , Force : true }); errApply != nil {
166+ return nil , errApply
167+ }
153168 return nil , err
154169 }
155- klog .Warningf ("Ignoring service %s/%s using different ports protocols" , svc .Namespace , svc .Name )
156- g .eventRecorder .Event (svc , v1 .EventTypeWarning , v1 .LoadBalancerPortsErrorReason , "LoadBalancers with multiple protocols are not supported." )
157- svcApplyStatus := corev1apply .ServiceStatus ().WithConditions (
158- metav1apply .Condition ().
159- WithType (v1 .LoadBalancerPortsError ).
160- WithStatus (metav1 .ConditionTrue ).
161- WithReason (v1 .LoadBalancerPortsErrorReason ).
162- WithMessage ("LoadBalancer with multiple protocols are not supported" ))
163- svcApply := corev1apply .Service (svc .Name , svc .Namespace ).WithStatus (svcApplyStatus )
164- if _ , errApply := g .client .CoreV1 ().Services (svc .Namespace ).ApplyStatus (ctx , svcApply , metav1.ApplyOptions {FieldManager : "gce-cloud-controller" , Force : true }); errApply != nil {
165- return nil , errApply
166- }
167- return nil , err
168170 }
169171
170172 klog .V (4 ).Infof ("EnsureLoadBalancer(%v, %v, %v, %v, %v): ensure %v loadbalancer" , clusterName , svc .Namespace , svc .Name , loadBalancerName , g .region , desiredScheme )
@@ -231,19 +233,21 @@ func (g *Cloud) UpdateLoadBalancer(ctx context.Context, clusterName string, svc
231233 // Services with multiples protocols are not supported by this controller, warn the users and sets
232234 // the corresponding Service Status Condition, but keep processing the Update to not break upgrades.
233235 // https://github.com/kubernetes/enhancements/tree/master/keps/sig-network/1435-mixed-protocol-lb
234- if err := checkMixedProtocol (svc .Spec .Ports ); err != nil && ! hasLoadBalancerPortsError (svc ) {
235- klog .Warningf ("Ignoring update for service %s/%s using different ports protocols" , svc .Namespace , svc .Name )
236- g .eventRecorder .Event (svc , v1 .EventTypeWarning , v1 .LoadBalancerPortsErrorReason , "LoadBalancer with multiple protocols are not supported." )
237- svcApplyStatus := corev1apply .ServiceStatus ().WithConditions (
238- metav1apply .Condition ().
239- WithType (v1 .LoadBalancerPortsError ).
240- WithStatus (metav1 .ConditionTrue ).
241- WithReason (v1 .LoadBalancerPortsErrorReason ).
242- WithMessage ("LoadBalancer with multiple protocols are not supported" ))
243- svcApply := corev1apply .Service (svc .Name , svc .Namespace ).WithStatus (svcApplyStatus )
244- if _ , errApply := g .client .CoreV1 ().Services (svc .Namespace ).ApplyStatus (ctx , svcApply , metav1.ApplyOptions {FieldManager : "gce-cloud-controller" , Force : true }); errApply != nil {
245- // the error is retried by the controller loop
246- return errApply
236+ if ! g .AlphaFeatureGate .Enabled (AlphaFeatureMultiProtocolLB ) {
237+ if err := checkMixedProtocol (svc .Spec .Ports ); err != nil && ! hasLoadBalancerPortsError (svc ) {
238+ klog .Warningf ("Ignoring update for service %s/%s using different ports protocols" , svc .Namespace , svc .Name )
239+ g .eventRecorder .Event (svc , v1 .EventTypeWarning , v1 .LoadBalancerPortsErrorReason , "LoadBalancer with multiple protocols are not supported." )
240+ svcApplyStatus := corev1apply .ServiceStatus ().WithConditions (
241+ metav1apply .Condition ().
242+ WithType (v1 .LoadBalancerPortsError ).
243+ WithStatus (metav1 .ConditionTrue ).
244+ WithReason (v1 .LoadBalancerPortsErrorReason ).
245+ WithMessage ("LoadBalancer with multiple protocols are not supported" ))
246+ svcApply := corev1apply .Service (svc .Name , svc .Namespace ).WithStatus (svcApplyStatus )
247+ if _ , errApply := g .client .CoreV1 ().Services (svc .Namespace ).ApplyStatus (ctx , svcApply , metav1.ApplyOptions {FieldManager : "gce-cloud-controller" , Force : true }); errApply != nil {
248+ // the error is retried by the controller loop
249+ return errApply
250+ }
247251 }
248252 }
249253
0 commit comments