Skip to content

Commit

Permalink
isNodeExists should return true when node is unmanaged nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinForReal authored and k8s-infra-cherrypick-robot committed Aug 2, 2023
1 parent dea0c0d commit 74a3d9f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/provider/azure_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (az *Cloud) InstanceExists(ctx context.Context, node *v1.Node) (bool, error
}
if unmanaged {
klog.V(4).Infof("InstanceExists: omitting unmanaged node %q", node.Name)
return false, nil
return true, nil
}

providerID := node.Spec.ProviderID
Expand Down
17 changes: 17 additions & 0 deletions pkg/provider/azure_instances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -989,4 +989,21 @@ func TestCloud_InstanceExists(t *testing.T) {
assert.NoError(t, err)
assert.False(t, exist)
})
t.Run("should return true when instance is not managed by azure", func(t *testing.T) {
ctx := context.Background()
cloud := GetTestCloud(ctrl)
cloud.unmanagedNodes = sets.New("foo")
node := &v1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Labels: map[string]string{
"kubernetes.azure.com/managed": "false",
},
},
}

exist, err := cloud.InstanceExists(ctx, node)
assert.NoError(t, err)
assert.True(t, exist)
})
}

0 comments on commit 74a3d9f

Please sign in to comment.