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

Use VM name instead of Node name for disk operations with Flex VMSS #2635

Merged
merged 1 commit into from Nov 2, 2022
Merged

Use VM name instead of Node name for disk operations with Flex VMSS #2635

merged 1 commit into from Nov 2, 2022

Conversation

okushchenko
Copy link
Contributor

What type of PR is this?

/kind bug

What this PR does / why we need it:

When using https://github.com/kubernetes-sigs/azuredisk-csi-driver with Flex VMSS, I observed that it fails to attach and detach disks from VMs. This is due to it trying to use k8s Node name instead of VM name when interacting with Azure APIs. This PR updates this logic to use a correct name.

Does this PR introduce a user-facing change?

Fixed a bug that prevents disks from being attached and detached for VMs in a Flex VMSS

@k8s-triage-robot
Copy link

Unknown CLA label state. Rechecking for CLA labels.

Send feedback to sig-contributor-experience at kubernetes/community.

/check-cla
/easycla

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Oct 27, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: okushchenko / name: Oleksandr Kushchenko (38ccddc)

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Oct 27, 2022
Copy link
Contributor

@zmyzheng zmyzheng left a comment

Choose a reason for hiding this comment

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

Thank you so much for finding this issue. You are right that we should use VM name rather than nodeName (OS hostName) when updating VM, so line 102,109, 182, 189 should be fixed as you proposed in the PR.

As for the rest lines, since CSI Driver is using nodename as the primary key to identify nodes/VMs, can we keep the way of using vmName? Only changing line 102,109, 182, 189 should be able to fix the issue.

pkg/provider/azure_controller_vmssflex.go Outdated Show resolved Hide resolved
pkg/provider/azure_controller_vmssflex.go Outdated Show resolved Hide resolved
Copy link
Contributor

@zmyzheng zmyzheng left a comment

Choose a reason for hiding this comment

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

Can you also update line 222 as well? Suggested change:

// UpdateVM updates a vm
func (fs *FlexScaleSet) UpdateVM(ctx context.Context, nodeName types.NodeName) error {
	vmName := mapNodeNameToVMName(nodeName)
	vm, err := fs.getVmssFlexVM(vmName, azcache.CacheReadTypeDefault)
	if err != nil {
		// if host doesn't exist, no need to update
		klog.Warningf("azureDisk - cannot find node %s, skip updating vm)", nodeName)
		return nil
	}

	nodeResourceGroup, err := fs.GetNodeResourceGroup(vmName)
	if err != nil {
		return err
	}

	defer func() {
		_ = fs.DeleteCacheForNode(vmName)
	}()

	klog.V(2).Infof("azureDisk - update(%s): vm(%s)", nodeResourceGroup, vmName)

	rerr := fs.VirtualMachinesClient.Update(ctx, nodeResourceGroup, *vm.Name, compute.VirtualMachineUpdate{}, "update_vm")
	klog.V(2).Infof("azureDisk - update(%s): vm(%s) - returned with %v", nodeResourceGroup, vmName, rerr)
	if rerr != nil {
		return rerr.Error()
	}
	return nil
}

@netlify
Copy link

netlify bot commented Oct 31, 2022

Deploy Preview for kubernetes-sigs-cloud-provide-azure canceled.

Name Link
🔨 Latest commit f8e383f
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cloud-provide-azure/deploys/63605e02b172130008d299ca

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 31, 2022
@okushchenko
Copy link
Contributor Author

@zmyzheng thanks for the quick review! I updated the PR with your suggestions and updated test cases for the UpdateVM method to account for the change that you proposed.

Copy link
Contributor

@zmyzheng zmyzheng left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot
Copy link
Contributor

@zmyzheng: changing LGTM is restricted to collaborators

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@okushchenko
Copy link
Contributor Author

@zmyzheng I rebased and squashed the commits to satisfy the bots, feel free to modify this PR however you think is necessary to get it merged.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 79.842% when pulling f8e383f on okushchenko:ok/vmssflex-disk into bd4e966 on kubernetes-sigs:master.

@zmyzheng
Copy link
Contributor

zmyzheng commented Nov 1, 2022

@feiskyer @andyzhangx could you help approve this PR?

@nilo19
Copy link
Contributor

nilo19 commented Nov 2, 2022

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 2, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nilo19, okushchenko, zmyzheng

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 Nov 2, 2022
@zmyzheng
Copy link
Contributor

zmyzheng commented Nov 2, 2022

/retest

@k8s-ci-robot
Copy link
Contributor

@zmyzheng: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@nilo19
Copy link
Contributor

nilo19 commented Nov 2, 2022

/ok-to-test
/retest

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Nov 2, 2022
@k8s-ci-robot k8s-ci-robot merged commit 4dea2db into kubernetes-sigs:master Nov 2, 2022
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

None yet

6 participants