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

feat(virtctl): Add boot order support to create vm #9629

Merged
merged 5 commits into from
Apr 24, 2023

Conversation

0xFelix
Copy link
Member

@0xFelix 0xFelix commented Apr 19, 2023

What this PR does / why we need it:

This adds a new param bootorder to flags of virtctl create vm,
which allows to specify the boot order of added volumes.

Support for fields of type *uint is added to params.go for this.
Also some refactorings are applied to virtctl create vm.

The param is added to the following flags:

  • volume-containerdisk
  • volume-datasource
  • volume-clone-pvc
  • volume-pvc

The method getInferFromVolume is added to vm.go to allow inferring
instancetypes or preferences from the disk with the lowest boot order or
if no boot order was specified the first volume.

Release note:

virtctl: Allow to specify the boot order of volumes when creating VMs

By moving the generation of the the default VM name to setDefaults() the
usage output of virtctl create vm stays the same between runs.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This moves the newVM func to be a method of createVM to be more
consistent with the rest of the code.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This adds support for *uint fields to params.go. It will be useful in
the next commit.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
@kubevirt-bot kubevirt-bot added 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. labels Apr 19, 2023
@0xFelix
Copy link
Member Author

0xFelix commented Apr 19, 2023

/cc @lyarwood


// getInferFromVolume returns the volume to infer the instancetype or preference from.
// It returns either the disk with the lowest boot order or the first volume in the VM spec.
func (c *createVM) getInferFromVolume(flag string, vm *v1.VirtualMachine) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

This is cool but out of scope for the commit and PR right?

Copy link
Member Author

Choose a reason for hiding this comment

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

IMO it is in scope because without #9631 we always want the infer flags to infer from the volume the VM booted from. Without this method this isn't possible.

@0xFelix
Copy link
Member Author

0xFelix commented Apr 19, 2023

/retest

This adds a new param 'bootorder' which allows to specify the boot order
of added volumes.

The param is added to the following flags:
  - volume-containerdisk
  - volume-datasource
  - volume-clone-pvc
  - volume-pvc

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
The method getInferFromVolume is added to vm.go to allow inferring
instancetypes or preferences from the disk with the lowest boot order or
if no boot order was specified the first volume.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
@0xFelix 0xFelix force-pushed the virtctl-create-vm-bootorder branch from 25affe2 to 6c21c2f Compare April 19, 2023 15:53
@lyarwood
Copy link
Member

lyarwood commented Apr 19, 2023

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Apr 19, 2023
@0xFelix
Copy link
Member Author

0xFelix commented Apr 20, 2023

/retest

@kubevirt-bot
Copy link
Contributor

kubevirt-bot commented Apr 20, 2023

@0xFelix: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubevirt-fossa 6c21c2f link false /test pull-kubevirt-fossa

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. I understand the commands that are listed here.

@alicefr
Copy link
Member

alicefr commented Apr 21, 2023

@0xFelix do we specify values like not ordered like '2' and then '4' or values greater than the total number of disks?

@@ -243,6 +258,9 @@ func (c *createVM) usage() string {
# Create a manifest for a VirtualMachine with a cloned DataSource and inferred instancetype and preference
{{ProgramName}} create vm --volume-datasource=src:my-annotated-ds --infer-instancetype --infer-preference

# Create a manifest for a VirtualMachine with multiple volumes and specified boot order
{{ProgramName}} create vm --volume-containerdisk=src:my.registry/my-image:my-tag --volume-datasource=src:my-ds,bootorder:1
Copy link
Member

Choose a reason for hiding this comment

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

Can't we simply use the volume name instead on the need to specify the type of volume? The name should be unique

Copy link
Member Author

Choose a reason for hiding this comment

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

The flags are not only setting the boot order of a volume but also add the volume itself. So I don't think this can be simplified any more.

@0xFelix
Copy link
Member Author

0xFelix commented Apr 21, 2023

@alicefr As we discovered offline it is not necessary to order the boot orders or make sure the highest boot order does not exceed the count of disks.

The only required validations are:

  • boot orders must be > 0
  • boot orders must not be duplicated

The description here is correct: http://kubevirt.io/api-reference/v0.59.0/definitions.html#_v1_disk

@alicefr
Copy link
Member

alicefr commented Apr 24, 2023

/approve

@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 Apr 24, 2023
@kubevirt-commenter-bot
Copy link

/retest-required
This bot automatically retries required jobs that failed/flaked on approved PRs.
Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@kubevirt-bot kubevirt-bot merged commit a8d1c0b into kubevirt:main Apr 24, 2023
35 of 36 checks passed
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

5 participants