From f0046a71949b6908908f4b597b67c8eeccb27f1f Mon Sep 17 00:00:00 2001 From: Dong Liu Date: Sat, 28 Apr 2018 13:43:29 +0800 Subject: [PATCH] Rename func to ensureNodeExistsByProviderID --- pkg/controller/cloud/node_controller.go | 10 +++++----- pkg/controller/cloud/node_controller_test.go | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/controller/cloud/node_controller.go b/pkg/controller/cloud/node_controller.go index 94b794f78d3..5ecf29a8357 100644 --- a/pkg/controller/cloud/node_controller.go +++ b/pkg/controller/cloud/node_controller.go @@ -154,7 +154,7 @@ func (cnc *CloudNodeController) updateNodeAddress(node *v1.Node, instances cloud return } // Node that isn't present according to the cloud provider shouldn't have its address updated - exists, err := ensureNodeExistsByProviderIDOrInstanceID(instances, node) + exists, err := ensureNodeExistsByProviderID(instances, node) if err != nil { // Continue to update node address when not sure the node is not exists glog.Errorf("%v", err) @@ -265,7 +265,7 @@ func (cnc *CloudNodeController) MonitorNode() { // Check with the cloud provider to see if the node still exists. If it // doesn't, delete the node immediately. - exists, err := ensureNodeExistsByProviderIDOrInstanceID(instances, node) + exists, err := ensureNodeExistsByProviderID(instances, node) if err != nil { glog.Errorf("Error getting data for node %s from cloud: %v", node.Name, err) continue @@ -438,9 +438,9 @@ func excludeTaintFromList(taints []v1.Taint, toExclude v1.Taint) []v1.Taint { return newTaints } -// ensureNodeExistsByProviderIDOrInstanceID checks if the instance exists by the provider id, -// If provider id is empty it calls instanceId with node name to get provider id -func ensureNodeExistsByProviderIDOrInstanceID(instances cloudprovider.Instances, node *v1.Node) (bool, error) { +// ensureNodeExistsByProviderID checks if the instance exists by the provider id, +// If provider id in spec is empty it calls instanceId with node name to get provider id +func ensureNodeExistsByProviderID(instances cloudprovider.Instances, node *v1.Node) (bool, error) { providerID := node.Spec.ProviderID if providerID == "" { var err error diff --git a/pkg/controller/cloud/node_controller_test.go b/pkg/controller/cloud/node_controller_test.go index 96a8a36d6f2..d26401383ba 100644 --- a/pkg/controller/cloud/node_controller_test.go +++ b/pkg/controller/cloud/node_controller_test.go @@ -41,7 +41,7 @@ import ( "github.com/stretchr/testify/assert" ) -func TestEnsureNodeExistsByProviderIDOrInstanceID(t *testing.T) { +func TestEnsureNodeExistsByProviderID(t *testing.T) { testCases := []struct { testName string @@ -149,7 +149,7 @@ func TestEnsureNodeExistsByProviderIDOrInstanceID(t *testing.T) { } instances, _ := fc.Instances() - exists, err := ensureNodeExistsByProviderIDOrInstanceID(instances, tc.node) + exists, err := ensureNodeExistsByProviderID(instances, tc.node) if tc.providerIDErr == nil { assert.NoError(t, err) }