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 return false
} }
func getPortsForLB(service *v1.Service) ([]*v1.ServicePort, error) { func getPortsForLB(service *v1.Service) []*v1.ServicePort {
var protocol v1.Protocol
ports := []*v1.ServicePort{} ports := []*v1.ServicePort{}
for i := range service.Spec.Ports { for i := range service.Spec.Ports {
sp := &service.Spec.Ports[i] 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) 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
return ports, nil
} }
func portsEqualForLB(x, y *v1.Service) bool { func portsEqualForLB(x, y *v1.Service) bool {
xPorts, err := getPortsForLB(x) xPorts := getPortsForLB(x)
if err != nil { yPorts := getPortsForLB(y)
return false
}
yPorts, err := getPortsForLB(y)
if err != nil {
return false
}
return portSlicesEqualForLB(xPorts, yPorts) return portSlicesEqualForLB(xPorts, yPorts)
} }