Commit 330517a3 authored by xiangpengzhao's avatar xiangpengzhao

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

parent e6ad5153
......@@ -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)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment