mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
Rename func to ensureNodeExistsByProviderID
This commit is contained in:
parent
050b583b96
commit
f0046a7194
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user