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

Add minimal VM Flavor API #6026

Merged
merged 5 commits into from Oct 13, 2021
Merged

Add minimal VM Flavor API #6026

merged 5 commits into from Oct 13, 2021

Conversation

akrejcir
Copy link
Contributor

@akrejcir akrejcir commented Jul 12, 2021

What this PR does / why we need it:
This PR adds minimal API and functionality for VM flavors.
The flavor resource will contain common configuration that can be reused by multiple VMs.

Changes in this PR:
Added new API resource group flavor.kubevirt.io, that contains flavor resources:

  • VirtualMachineFlavor
  • VirtualMachineClusterFlavor

Added Flavor field to VirtualMachineSpec that specifies which flavor the VM uses.

When a VM is created, the validating webhook checks if the flavor exists and can be applied to VMI without conflict.

Release note:

Implemented minimal VirtualMachineFlavor functionality.

Added new API resources in 'flavor.kubevirt.io':
- VirtualMachineFlavor
- VirtualMachineClusterFlavor

Added 'Flavor' field to 'VirtualMachineSpec', which contains reference to a flavor.

@kubevirt-bot kubevirt-bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Jul 12, 2021
@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 dco-signoff: yes Indicates the PR's author has DCO signed all their commits. size/XXL labels Jul 12, 2021
@davidvossel
Copy link
Member

/cc @davidvossel

Copy link
Member

@davidvossel davidvossel left a comment

Choose a reason for hiding this comment

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

looks great! i just had one minor comment

@kubevirt-bot kubevirt-bot added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Aug 17, 2021
@akrejcir akrejcir changed the title WIP - Add VM Flavor API Add minimal VM Flavor API Aug 17, 2021
@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Aug 17, 2021
@akrejcir
Copy link
Contributor Author

/cc @kwiesmueller @ksimon1 @omeryahud

@akrejcir akrejcir marked this pull request as ready for review August 17, 2021 09:47
@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 Aug 17, 2021
pkg/flavor/flavor.go Outdated Show resolved Hide resolved
pkg/flavor/flavor.go Outdated Show resolved Hide resolved
return flavorSpec.DefaultProfile, nil
}

for i := range flavorSpec.CustomProfiles {

Choose a reason for hiding this comment

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

You can use

Suggested change
for i := range flavorSpec.CustomProfiles {
for _, customProfile := range flavorSpec.CustomProfiles {

instead of the [i] access.

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 wanted to avoid unnecessary copying of structs. But it is probably insignificant performance boost.

pkg/flavor/flavor.go Outdated Show resolved Hide resolved
staging/src/kubevirt.io/client-go/api/v1/defaults.go Outdated Show resolved Hide resolved
@akrejcir
Copy link
Contributor Author

Moving to draft. Missing validating webhook for flavors.

@akrejcir akrejcir marked this pull request as draft August 18, 2021 08:12
@kubevirt-bot kubevirt-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 18, 2021
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 6, 2021
@akrejcir
Copy link
Contributor Author

akrejcir commented Oct 7, 2021

/retest

4 similar comments
@akrejcir
Copy link
Contributor Author

akrejcir commented Oct 7, 2021

/retest

@akrejcir
Copy link
Contributor Author

akrejcir commented Oct 7, 2021

/retest

@akrejcir
Copy link
Contributor Author

akrejcir commented Oct 7, 2021

/retest

@davidvossel
Copy link
Member

/retest

Copy link
Member

@davidvossel davidvossel left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

well done

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: davidvossel

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 7, 2021
@kubevirt-commenter-bot
Copy link

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

@akrejcir
Copy link
Contributor Author

akrejcir commented Oct 8, 2021

/retest

This will make adding API definitions easier
in the following commit.

Signed-off-by: Andrej Krejcir <akrejcir@redhat.com>
Added flavor API defintions and generated client.

Signed-off-by: Andrej Krejcir <akrejcir@redhat.com>
Signed-off-by: Andrej Krejcir <akrejcir@redhat.com>
Changes:
- Added flavor package with common functionality to get flavor and apply it to VMI.
- Added flavor FlavorMatcher field to VM API, which references a flavor.
- VM validating webhook checks that the flavor exists, and can be applied to VMI without conflicts.
- virt-controller applies the flavor to VMI when a VM is started

Signed-off-by: Andrej Krejcir <akrejcir@redhat.com>
The webhook succeeds if:
- There is at least one profile
- At most one profile is set as default
- Each profile can be applied to an empty VMI spec without conflicts

Signed-off-by: Andrej Krejcir <akrejcir@redhat.com>
@kubevirt-bot kubevirt-bot removed the lgtm Indicates that a PR is ready to be merged. label Oct 8, 2021
@akrejcir
Copy link
Contributor Author

akrejcir commented Oct 8, 2021

@davidvossel, I needed to rebase this. Can you approve it again?

@akrejcir
Copy link
Contributor Author

/retest

1 similar comment
@akrejcir
Copy link
Contributor Author

/retest

@davidvossel
Copy link
Member

/lgtm

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. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API 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/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants