Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix VM provider ID to match node ID #1293

Merged

Conversation

CecileRobertMichon
Copy link
Contributor

@CecileRobertMichon CecileRobertMichon commented Apr 6, 2021

What type of PR is this?
/kind bug

What this PR does / why we need it:

Cloud provider sets the ID by doing azure + :// + ID

https://github.com/kubernetes-sigs/cloud-provider-azure/blob/28f04006af77503360c42c5c3930ea707b897108/pkg/node/node.go#L63

Whereas CAPZ sets the ID with 3 slashes: azure+ :/// + ID:

https://github.com/kubernetes-sigs/cluster-api-provider-azure/blob/master/azure/services/virtualmachines/virtualmachines.go#L97

the ID itself starts with a / so it ends up being 3 vs 4 slashes.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #1292

Special notes for your reviewer: This also makes the Machine provider IDs consistent with MachinePool instance provider IDs which were already prefixed with azure:// https://github.com/kubernetes-sigs/cluster-api-provider-azure/blob/master/azure/services/scalesets/scalesets.go#L122

Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests

Release note:

Fix VM provider ID to match node ID

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. labels Apr 6, 2021
@k8s-ci-robot k8s-ci-robot added area/provider/azure Issues or PRs related to azure provider sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 6, 2021
@CecileRobertMichon
Copy link
Contributor Author

This should not be a breaking change as the providerID is mutable and should get reconciled on existing clusters, verifying that assumption.

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 6, 2021
@@ -38,14 +38,14 @@ var sampleSubjectFactory = []infrav1.UserAssignedIdentity{
}

var expectedVMSDKObject = map[string]*compute.VirtualMachineIdentityUserAssignedIdentitiesValue{
"foo": {},
"bar": {},
"/foo": {},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nader-ziada need your help figuring out if this is indeed what we want... The comment on UserAssignedIdentitiesToVMSDK say:

// The user identity dictionary key references will be ARM resource ids in the form: // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.

So I think we expect only the leading azure:// to be removed, the rest (including the leading /) should be kept there?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I believe you are correct to assume we should keep one /

@CecileRobertMichon
Copy link
Contributor Author

Before:

k get machines
NAME                                       PROVIDERID                                                                                                                                                                              PHASE     VERSION
default-template-control-plane-gfpg6       azure:////subscriptions/85d99e6d-f6d6-408f-a9f1-b7a97237d5c4/resourceGroups/default-template/providers/Microsoft.Compute/virtualMachines/default-template-control-plane-fhrvh           Running   v1.19.7
default-template-md-0-6df9f4c7fd-6vtn6     azure:////subscriptions/85d99e6d-f6d6-408f-a9f1-b7a97237d5c4/resourceGroups/default-template/providers/Microsoft.Compute/virtualMachines/default-template-md-0-ftcks                    Running   v1.19.7
default-template-md-0-6df9f4c7fd-82lmk     azure:////subscriptions/85d99e6d-f6d6-408f-a9f1-b7a97237d5c4/resourceGroups/default-template/providers/Microsoft.Compute/virtualMachines/default-template-md-0-5hzg2                    Running   v1.19.7
machinepool-template-control-plane-w6khm   azure:////subscriptions/85d99e6d-f6d6-408f-a9f1-b7a97237d5c4/resourceGroups/machinepool-template/providers/Microsoft.Compute/virtualMachines/machinepool-template-control-plane-mfh7w   Running   v1.19.7

After:

k get machines
NAME                                       PROVIDERID                                                                                                                                                                             PHASE     VERSION
default-template-control-plane-gfpg6       azure:///subscriptions/85d99e6d-f6d6-408f-a9f1-b7a97237d5c4/resourceGroups/default-template/providers/Microsoft.Compute/virtualMachines/default-template-control-plane-fhrvh           Running   v1.19.7
default-template-md-0-6df9f4c7fd-6vtn6     azure:///subscriptions/85d99e6d-f6d6-408f-a9f1-b7a97237d5c4/resourceGroups/default-template/providers/Microsoft.Compute/virtualMachines/default-template-md-0-ftcks                    Running   v1.19.7
default-template-md-0-6df9f4c7fd-82lmk     azure:///subscriptions/85d99e6d-f6d6-408f-a9f1-b7a97237d5c4/resourceGroups/default-template/providers/Microsoft.Compute/virtualMachines/default-template-md-0-5hzg2                    Running   v1.19.7
machinepool-template-control-plane-w6khm   azure:///subscriptions/85d99e6d-f6d6-408f-a9f1-b7a97237d5c4/resourceGroups/machinepool-template/providers/Microsoft.Compute/virtualMachines/machinepool-template-control-plane-mfh7w   Running   v1.19.7

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 6, 2021
@CecileRobertMichon
Copy link
Contributor Author

/retest

azure/converters/identity.go Outdated Show resolved Hide resolved
test/e2e/azure_test.go Show resolved Hide resolved
@nikhita
Copy link
Member

nikhita commented Apr 7, 2021

creating a (dummy) approve comment to re-trigger CI, the approval mechanism was broken for a bit - kubernetes/test-infra#21687

/approve

@nader-ziada
Copy link
Contributor

lgtm (other than Shyam comments)

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 7, 2021
@shysank
Copy link
Contributor

shysank commented Apr 7, 2021

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 7, 2021
@nader-ziada
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nader-ziada, nikhita

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 7, 2021
@k8s-ci-robot k8s-ci-robot merged commit 7b8e792 into kubernetes-sigs:master Apr 7, 2021
@k8s-ci-robot k8s-ci-robot added this to the v0.5.0 milestone Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/provider/azure Issues or PRs related to azure provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provider ID should only append two slashes to match cloud provider node provider ID format
5 participants