fix review

Signed-off-by: Patrik Cyvoct <patrik@ptrk.io>
This commit is contained in:
Patrik Cyvoct
2020-10-22 10:44:04 +02:00
parent d562b6924a
commit 0153b96ab8
11 changed files with 242 additions and 115 deletions

View File

@@ -179,6 +179,12 @@ func dropServiceDisabledFields(newSvc *api.Service, oldSvc *api.Service) {
if !utilfeature.DefaultFeatureGate.Enabled(features.ServiceTopology) && !topologyKeysInUse(oldSvc) {
newSvc.Spec.TopologyKeys = nil
}
if !utilfeature.DefaultFeatureGate.Enabled(features.LoadBalancerIPMode) && !loadbalancerIPModeInUse(oldSvc) {
for _, ing := range newSvc.Status.LoadBalancer.Ingress {
ing.IPMode = nil
}
}
}
// returns true if svc.Spec.ServiceIPFamily field is in use
@@ -202,6 +208,19 @@ func topologyKeysInUse(svc *api.Service) bool {
return len(svc.Spec.TopologyKeys) > 0
}
// returns true is svc.Status.LoadBalancer.Ingress[].IPMode fields are in use
func loadbalancerIPModeInUse(svc *api.Service) bool {
if svc == nil {
return false
}
for _, ing := range svc.Status.LoadBalancer.Ingress {
if ing.IPMode != nil {
return true
}
}
return false
}
type serviceStatusStrategy struct {
Strategy
}