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

Allow LUN disks to be hotplugged #10529

Merged
merged 3 commits into from Oct 26, 2023

Conversation

alromeros
Copy link
Contributor

@alromeros alromeros commented Oct 6, 2023

What this PR does / why we need it:

This PR aims to allow LUN disks to be hotplugged, instead of simply allowing regular Disk types.

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 # https://bugzilla.redhat.com/show_bug.cgi?id=2211266

Special notes for your reviewer:

Release note:

Allow LUN disks to be hotplugged

@kubevirt-bot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@kubevirt-bot kubevirt-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/L labels Oct 6, 2023
@alromeros
Copy link
Contributor Author

/test pull-kubevirt-e2e-k8s-1.28-sig-storage
/test pull-kubevirt-e2e-k8s-1.27-sig-storage
/test pull-kubevirt-e2e-k8s-1.26-sig-storage

@alicefr
Copy link
Member

alicefr commented Oct 9, 2023

/cc

@alromeros
Copy link
Contributor Author

/test pull-kubevirt-e2e-k8s-1.28-sig-storage

@alromeros
Copy link
Contributor Author

/test pull-kubevirt-e2e-k8s-1.28-sig-storage

@alromeros
Copy link
Contributor Author

/test pull-kubevirt-e2e-k8s-1.27-sig-storage
/test pull-kubevirt-e2e-k8s-1.26-sig-storage
/test pull-kubevirt-e2e-k8s-1.28-sig-storage

Signed-off-by: Alvaro Romero <alromero@redhat.com>
@alromeros alromeros marked this pull request as ready for review October 20, 2023 12:02
Signed-off-by: Alvaro Romero <alromero@redhat.com>
@alromeros alromeros changed the title [WIP] Allow LUN disks to be hotplugged Allow LUN disks to be hotplugged Oct 20, 2023
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 20, 2023
@alromeros
Copy link
Contributor Author

Hey @alicefr, I'm waiting to see how tests behave but this should be ready for review. Thanks!

@alromeros
Copy link
Contributor Author

/test pull-kubevirt-e2e-k8s-1.28-sig-storage

pkg/virt-launcher/virtwrap/converter/converter.go Outdated Show resolved Hide resolved
)

var (
serial string
cache string
serial string
Copy link
Member

Choose a reason for hiding this comment

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

Can you avoid global vars? (possibly in a follow up)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All virtctl commands use (and require) global variables to store flags, I think we should follow that standard.

Copy link
Member

Choose a reason for hiding this comment

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

That is not true and IMO using global variables is not a very good standard.

e.g. virtctl create {vm|instancetype|preference} do neither use nor require them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aw, you are right, I checked our other commands and assumed they were all the same 🤦 Anyway this command uses some common global variables that would require a considerable refactor in all vm commands, so I prefer to leave that for another PR.

pkg/virtctl/vm/add_volume.go Show resolved Hide resolved
pkg/virtctl/vm/add_volume_test.go Show resolved Hide resolved
tests/storage/hotplug.go Outdated Show resolved Hide resolved
tests/storage/hotplug.go Outdated Show resolved Hide resolved

vm, err = virtClient.VirtualMachine(testsuite.GetTestNamespace(vmi)).Create(context.Background(), tests.NewRandomVirtualMachine(vmi, true))
Expect(err).ToNot(HaveOccurred())
Eventually(func() bool {
Copy link
Member

Choose a reason for hiding this comment

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

You could make beReady() from vm_test.go public and use it here to:

Eventually(ThisVM(vm), 300*time.Second, 1*time.Second).Should(Not(beReady()))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prefer to leave that for a possible follow-up, there are several instances of this code block between all tests and for consistency I think it'd be better to take out all the beCreated, beReady, beRestarted, etc. functions.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, do you want to create an issue for the follow-ups?

@alromeros
Copy link
Contributor Author

/retest-required

@alromeros alromeros force-pushed the allow-lun-hotplug branch 2 times, most recently from 7b0c064 to 79d6f76 Compare October 24, 2023 10:26
Copy link
Member

@0xFelix 0xFelix left a comment

Choose a reason for hiding this comment

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

Thanks

/lgtm


vm, err = virtClient.VirtualMachine(testsuite.GetTestNamespace(vmi)).Create(context.Background(), tests.NewRandomVirtualMachine(vmi, true))
Expect(err).ToNot(HaveOccurred())
Eventually(func() bool {
Copy link
Member

Choose a reason for hiding this comment

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

Agreed, do you want to create an issue for the follow-ups?

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Oct 24, 2023
},
VolumeSource: volumeSource,
DryRun: *dryRunOption,
}
if diskType == "" || diskType == "disk" {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: you could replace this with a switch case

nodeName = tests.NodeNameWithHandler()
address, device = tests.CreateSCSIDisk(nodeName, []string{})
By(fmt.Sprintf("Create PVC with SCSI disk %s", device))
pv, pvc, err = tests.CreatePVandPVCwithSCSIDisk(nodeName, device, util.NamespaceTestDefault, "scsi-disks", "scsipv", "scsipvc")
Copy link
Member

@alicefr alicefr Oct 24, 2023

Choose a reason for hiding this comment

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

Do the namespaces always match for util.NamespaceTestDefault and the testsuite.GetTestNamespace? Could happen that you create the PVC and the VM in 2 different namespaces?

Copy link
Contributor Author

@alromeros alromeros Oct 24, 2023

Choose a reason for hiding this comment

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

I guess it shouldn't be a problem but will only use the former for consistency.

removeVolumeVM(vm.Name, vm.Namespace, testNewVolume1, false)
removeVolumeVM(vm.Name, vm.Namespace, testNewVolume2, false)

verifyVolumeAndDiskVMRemoved(vm, testNewVolume1, testNewVolume2)
Copy link
Member

Choose a reason for hiding this comment

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

Can we move this into the AfterEach?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think having a different number of volumes between tests overcomplicates this a little bit and would look less nice, prefer to leave it like this.

@alicefr
Copy link
Member

alicefr commented Oct 24, 2023

I left a couple of questions but the code looks good!
/lgtm

Signed-off-by: Alvaro Romero <alromero@redhat.com>
@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Oct 24, 2023
@alicefr
Copy link
Member

alicefr commented Oct 25, 2023

@alromeros thanks for the work, looks good!

/approve
/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Oct 25, 2023
@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alicefr

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

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 25, 2023
@alromeros
Copy link
Contributor Author

/test pull-kubevirt-e2e-k8s-1.26-sig-storage

1 similar comment
@alromeros
Copy link
Contributor Author

/test pull-kubevirt-e2e-k8s-1.26-sig-storage

@kubevirt-bot kubevirt-bot merged commit f3f020d into kubevirt:main Oct 26, 2023
37 checks passed
@alromeros
Copy link
Contributor Author

/cherrypick release-1.1

@kubevirt-bot
Copy link
Contributor

@alromeros: new pull request created: #10909

In response to this:

/cherrypick release-1.1

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.

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. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm 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. size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants