Merge pull request #60692 from adnavare/bug/60466

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Cleanup the use of ExternalID as it is deprecated

The patch removes ExternalID usage from node_controller
and node_lifecycle_oontroller. The code instead uses InstanceID
which returns the cloud provider ID as well.

fixes #60466
This commit is contained in:
Kubernetes Submit Queue
2018-04-09 11:58:12 -07:00
committed by GitHub
16 changed files with 8 additions and 128 deletions

View File

@@ -417,11 +417,9 @@ func ensureNodeExistsByProviderIDOrExternalID(instances cloudprovider.Instances,
exists, err := instances.InstanceExistsByProviderID(context.TODO(), node.Spec.ProviderID)
if err != nil {
providerIDErr := err
_, err = instances.ExternalID(context.TODO(), types.NodeName(node.Name))
_, err = instances.InstanceID(context.TODO(), types.NodeName(node.Name))
//<anupn> Changing the check as InstanceID does not return error
if err == nil {
return true, nil
}
if err == cloudprovider.InstanceNotFound {
return false, nil
}

View File

@@ -90,7 +90,7 @@ func TestEnsureNodeExistsByProviderIDOrNodeName(t *testing.T) {
providerIDErr: errors.New("unimplemented"),
existsByNodeName: true,
nodeNameErr: nil,
expectedCalls: []string{"instance-exists-by-provider-id", "external-id"},
expectedCalls: []string{"instance-exists-by-provider-id", "instance-id"},
node: &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: "node0",
@@ -106,7 +106,7 @@ func TestEnsureNodeExistsByProviderIDOrNodeName(t *testing.T) {
providerIDErr: errors.New("unimplemented"),
existsByNodeName: false,
nodeNameErr: cloudprovider.InstanceNotFound,
expectedCalls: []string{"instance-exists-by-provider-id", "external-id"},
expectedCalls: []string{"instance-exists-by-provider-id", "instance-id"},
node: &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: "node0",
@@ -138,7 +138,7 @@ func TestEnsureNodeExistsByProviderIDOrNodeName(t *testing.T) {
"expected exist by provider id to be `%t` but got `%t`",
tc.existsByProviderID, exists)
assert.False(t, tc.existsByNodeName && tc.existsByNodeName != exists,
assert.False(t, tc.existsByNodeName && tc.existsByNodeName == exists,
"expected exist by node name to be `%t` but got `%t`", tc.existsByNodeName, exists)
assert.False(t, !tc.existsByNodeName && !tc.existsByProviderID && exists,

View File

@@ -178,7 +178,7 @@ func ExistsInCloudProvider(cloud cloudprovider.Interface, nodeName types.NodeNam
if !ok {
return false, fmt.Errorf("%v", ErrCloudInstance)
}
if _, err := instances.ExternalID(context.TODO(), nodeName); err != nil {
if _, err := instances.InstanceID(context.TODO(), nodeName); err != nil {
if err == cloudprovider.InstanceNotFound {
return false, nil
}