Rename func to ensureNodeExistsByProviderID

This commit is contained in:
Dong Liu 2018-04-28 13:43:29 +08:00
parent 050b583b96
commit f0046a7194
2 changed files with 7 additions and 7 deletions

View File

@ -154,7 +154,7 @@ func (cnc *CloudNodeController) updateNodeAddress(node *v1.Node, instances cloud
return return
} }
// Node that isn't present according to the cloud provider shouldn't have its address updated // 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 { if err != nil {
// Continue to update node address when not sure the node is not exists // Continue to update node address when not sure the node is not exists
glog.Errorf("%v", err) 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 // Check with the cloud provider to see if the node still exists. If it
// doesn't, delete the node immediately. // doesn't, delete the node immediately.
exists, err := ensureNodeExistsByProviderIDOrInstanceID(instances, node) exists, err := ensureNodeExistsByProviderID(instances, node)
if err != nil { if err != nil {
glog.Errorf("Error getting data for node %s from cloud: %v", node.Name, err) glog.Errorf("Error getting data for node %s from cloud: %v", node.Name, err)
continue continue
@ -438,9 +438,9 @@ func excludeTaintFromList(taints []v1.Taint, toExclude v1.Taint) []v1.Taint {
return newTaints return newTaints
} }
// ensureNodeExistsByProviderIDOrInstanceID checks if the instance exists by the provider id, // ensureNodeExistsByProviderID checks if the instance exists by the provider id,
// If provider id is empty it calls instanceId with node name to get provider id // If provider id in spec is empty it calls instanceId with node name to get provider id
func ensureNodeExistsByProviderIDOrInstanceID(instances cloudprovider.Instances, node *v1.Node) (bool, error) { func ensureNodeExistsByProviderID(instances cloudprovider.Instances, node *v1.Node) (bool, error) {
providerID := node.Spec.ProviderID providerID := node.Spec.ProviderID
if providerID == "" { if providerID == "" {
var err error var err error

View File

@ -41,7 +41,7 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
func TestEnsureNodeExistsByProviderIDOrInstanceID(t *testing.T) { func TestEnsureNodeExistsByProviderID(t *testing.T) {
testCases := []struct { testCases := []struct {
testName string testName string
@ -149,7 +149,7 @@ func TestEnsureNodeExistsByProviderIDOrInstanceID(t *testing.T) {
} }
instances, _ := fc.Instances() instances, _ := fc.Instances()
exists, err := ensureNodeExistsByProviderIDOrInstanceID(instances, tc.node) exists, err := ensureNodeExistsByProviderID(instances, tc.node)
if tc.providerIDErr == nil { if tc.providerIDErr == nil {
assert.NoError(t, err) assert.NoError(t, err)
} }