Commit c7988bae authored by Nic Cope's avatar Nic Cope

Get the node before attempting to get its Alias IP ranges

This allows us to fail fast if the node doesn't exist, and to record node status changes if we fail to 'allocate' a CIDR.
parent 09cf6c97
...@@ -191,10 +191,14 @@ func (ca *cloudCIDRAllocator) AllocateOrOccupyCIDR(node *v1.Node) error { ...@@ -191,10 +191,14 @@ func (ca *cloudCIDRAllocator) AllocateOrOccupyCIDR(node *v1.Node) error {
// updateCIDRAllocation assigns CIDR to Node and sends an update to the API server. // updateCIDRAllocation assigns CIDR to Node and sends an update to the API server.
func (ca *cloudCIDRAllocator) updateCIDRAllocation(nodeName string) error { func (ca *cloudCIDRAllocator) updateCIDRAllocation(nodeName string) error {
var err error
var node *v1.Node
defer ca.removeNodeFromProcessing(nodeName) defer ca.removeNodeFromProcessing(nodeName)
node, err := ca.nodeLister.Get(nodeName)
if err != nil {
glog.Errorf("Failed while getting node %v for updating Node.Spec.PodCIDR: %v", nodeName, err)
return err
}
cidrs, err := ca.cloud.AliasRanges(types.NodeName(nodeName)) cidrs, err := ca.cloud.AliasRanges(types.NodeName(nodeName))
if err != nil { if err != nil {
nodeutil.RecordNodeStatusChange(ca.recorder, node, "CIDRNotAvailable") nodeutil.RecordNodeStatusChange(ca.recorder, node, "CIDRNotAvailable")
...@@ -210,12 +214,6 @@ func (ca *cloudCIDRAllocator) updateCIDRAllocation(nodeName string) error { ...@@ -210,12 +214,6 @@ func (ca *cloudCIDRAllocator) updateCIDRAllocation(nodeName string) error {
} }
podCIDR := cidr.String() podCIDR := cidr.String()
node, err = ca.nodeLister.Get(nodeName)
if err != nil {
glog.Errorf("Failed while getting node %v for updating Node.Spec.PodCIDR: %v", nodeName, err)
return err
}
if node.Spec.PodCIDR == podCIDR { if node.Spec.PodCIDR == podCIDR {
glog.V(4).Infof("Node %v already has allocated CIDR %v. It matches the proposed one.", node.Name, podCIDR) glog.V(4).Infof("Node %v already has allocated CIDR %v. It matches the proposed one.", node.Name, podCIDR)
// We don't return here, in order to set the NetworkUnavailable condition later below. // We don't return here, in order to set the NetworkUnavailable condition later below.
......
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