fix review

Signed-off-by: Patrik Cyvoct <patrik@ptrk.io>
This commit is contained in:
Patrik Cyvoct 2020-10-30 09:20:43 +01:00
parent 88330eafef
commit 7bdf2af648
No known key found for this signature in database
GPG Key ID: 4334D82B950FB63A
4 changed files with 6 additions and 5 deletions

View File

@ -169,10 +169,10 @@ func SetDefaults_Service(obj *v1.Service) {
if utilfeature.DefaultFeatureGate.Enabled(features.LoadBalancerIPMode) &&
obj.Spec.Type == v1.ServiceTypeLoadBalancer {
ipMode := v1.LoadBalancerIPModeVIP
for _, ing := range obj.Status.LoadBalancer.Ingress {
if ing.IPMode == nil {
ipMode := v1.LoadBalancerIPModeVIP
ing.IPMode = &ipMode
}
}

View File

@ -4404,7 +4404,7 @@ func TestLoadBalancerIngressRouteTypeProxy(t *testing.T) {
t.Errorf("Failed to get ipvs services, err: %v", err)
}
if len(services) != testCase.expectedServices {
t.Errorf("Expect %d ipvs services, got %d", testCase.expectedServices, len(services))
t.Errorf("Expected %d ipvs services, got %d", testCase.expectedServices, len(services))
}
}
}

View File

@ -166,16 +166,17 @@ func (sct *ServiceChangeTracker) newBaseServiceInfo(port *v1.ServicePort, servic
// Obtain Load Balancer Ingress IPs
var allIncorrectIPs []string
for _, ing := range service.Status.LoadBalancer.Ingress {
// []string{ing.IP} have a len of 1, so len(correctIPs) + len(incorrectIPs) == 1
correctIPs, incorrectIPs := utilproxy.FilterIncorrectIPVersion([]string{ing.IP}, sct.ipFamily)
// len is either 1 or 0
if len(correctIPs) == 1 {
// Update the LoadBalancerStatus with the filtered IPs
// Update the LoadBalancerStatus with the filtered IP
info.loadBalancerStatus.Ingress = append(info.loadBalancerStatus.Ingress, ing)
continue
}
// here len(incorrectIPs) == 1
// here len(incorrectIPs) == 1 since len(correctIPs) == 0
allIncorrectIPs = append(allIncorrectIPs, incorrectIPs[0])
}

View File

@ -208,7 +208,7 @@ func topologyKeysInUse(svc *api.Service) bool {
return len(svc.Spec.TopologyKeys) > 0
}
// returns true is svc.Status.LoadBalancer.Ingress[].IPMode fields are in use
// returns true when the LoadBalancer Ingress IPMode fields are in use.
func loadbalancerIPModeInUse(svc *api.Service) bool {
if svc == nil {
return false