Return error instead of crashing apiserver when updating services with duplicate nodeports

This commit is contained in:
xiangpengzhao 2017-11-07 14:32:38 +08:00
parent e6ad515315
commit 330517a3a0

View File

@ -617,9 +617,8 @@ func (rs *REST) updateNodePorts(oldService, newService *api.Service, nodePortOp
servicePort.NodePort = int32(nodePortNumber)
nodePort.NodePort = servicePort.NodePort
}
// Detect duplicate node ports; this should have been caught by validation, so we panic
if containsNodePort(newNodePorts, nodePort) {
panic("duplicate node port")
return fmt.Errorf("duplicate nodePort: %v", nodePort)
}
newNodePorts = append(newNodePorts, nodePort)
}