Convert error messages to use event recorder

remove mix protocol validation
remove check nil
This commit is contained in:
wccsama 2019-10-15 13:35:55 +08:00
parent 63bd1d7a5c
commit 18cf49e3df

View File

@ -548,33 +548,18 @@ func (s *ServiceController) needsUpdate(oldService *v1.Service, newService *v1.S
return false
}
func getPortsForLB(service *v1.Service) ([]*v1.ServicePort, error) {
var protocol v1.Protocol
func getPortsForLB(service *v1.Service) []*v1.ServicePort {
ports := []*v1.ServicePort{}
for i := range service.Spec.Ports {
sp := &service.Spec.Ports[i]
// The check on protocol was removed here. The cloud provider itself is now responsible for all protocol validation
ports = append(ports, sp)
if protocol == "" {
protocol = sp.Protocol
} else if protocol != sp.Protocol && wantsLoadBalancer(service) {
// TODO: Convert error messages to use event recorder
return nil, fmt.Errorf("mixed protocol external load balancers are not supported")
}
}
return ports, nil
return ports
}
func portsEqualForLB(x, y *v1.Service) bool {
xPorts, err := getPortsForLB(x)
if err != nil {
return false
}
yPorts, err := getPortsForLB(y)
if err != nil {
return false
}
xPorts := getPortsForLB(x)
yPorts := getPortsForLB(y)
return portSlicesEqualForLB(xPorts, yPorts)
}