Skip to content

Commit

Permalink
Merge pull request #4393 from MartinForReal/shafan/virtualnode
Browse files Browse the repository at this point in the history
InstanceExists should return true when node is unmanaged ones
  • Loading branch information
k8s-ci-robot committed Aug 2, 2023
2 parents bbf38c1 + 3b7b486 commit ccb4f3c
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 @@ -231,7 +231,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 ccb4f3c

Please sign in to comment.