diff --git a/pkg/controller/cloud/node_controller.go b/pkg/controller/cloud/node_controller.go index 2c6f2c64409..099d6c87706 100644 --- a/pkg/controller/cloud/node_controller.go +++ b/pkg/controller/cloud/node_controller.go @@ -337,6 +337,21 @@ func (cnc *CloudNodeController) AddCloudNode(obj interface{}) { } err := clientretry.RetryOnConflict(UpdateNodeSpecBackoff, func() error { + // TODO(wlan0): Move this logic to the route controller using the node taint instead of condition + // Since there are node taints, do we still need this? + // This condition marks the node as unusable until routes are initialized in the cloud provider + if cnc.cloud.ProviderName() == "gce" { + if err := nodeutil.SetNodeCondition(cnc.kubeClient, types.NodeName(node.Name), v1.NodeCondition{ + Type: v1.NodeNetworkUnavailable, + Status: v1.ConditionTrue, + Reason: "NoRouteCreated", + Message: "Node created without a route", + LastTransitionTime: metav1.Now(), + }); err != nil { + return err + } + } + curNode, err := cnc.kubeClient.CoreV1().Nodes().Get(node.Name, metav1.GetOptions{}) if err != nil { return err @@ -374,19 +389,6 @@ func (cnc *CloudNodeController) AddCloudNode(obj interface{}) { curNode.ObjectMeta.Labels[kubeletapis.LabelInstanceType] = instanceType } - // TODO(wlan0): Move this logic to the route controller using the node taint instead of condition - // Since there are node taints, do we still need this? - // This condition marks the node as unusable until routes are initialized in the cloud provider - if cnc.cloud.ProviderName() == "gce" { - curNode.Status.Conditions = append(node.Status.Conditions, v1.NodeCondition{ - Type: v1.NodeNetworkUnavailable, - Status: v1.ConditionTrue, - Reason: "NoRouteCreated", - Message: "Node created without a route", - LastTransitionTime: metav1.Now(), - }) - } - if zones, ok := cnc.cloud.Zones(); ok { zone, err := getZoneByProviderIDOrName(zones, curNode) if err != nil { diff --git a/pkg/controller/testutil/test_utils.go b/pkg/controller/testutil/test_utils.go index b6487e0a791..585298ffa5a 100644 --- a/pkg/controller/testutil/test_utils.go +++ b/pkg/controller/testutil/test_utils.go @@ -265,7 +265,7 @@ func (m *FakeNodeHandler) UpdateStatus(node *v1.Node) (*v1.Node, error) { // PatchStatus patches a status of a Node in the fake store. func (m *FakeNodeHandler) PatchStatus(nodeName string, data []byte) (*v1.Node, error) { m.RequestCount++ - return &v1.Node{}, nil + return m.Patch(nodeName, types.StrategicMergePatchType, data, "status") } // Watch watches Nodes in a fake store.