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

Generate correct node affinity if no values are passed #1557

Merged
merged 3 commits into from
Feb 8, 2023

Conversation

embik
Copy link
Member

@embik embik commented Feb 8, 2023

What this PR does / why we need it:
We discovered during QA that if you pass affinity settings for KubeVirt machines like this one:

affinity:
  nodeAffinityPreset:
    key: test
    type: hard

machine-controller will fail to create the VM because of this error:

E0208 10:40:53.418009       1 machine_controller.go:382] Failed to reconcile machine "mbhl5h4xkc-worker-bbxjzj-544cc46784-tz4rk": failed to create machine at cloudprovider, due to failed to create vmi: admission webhook "virtualmachine-validator.kubevirt.io" denied the request: spec.template.spec.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].values: Required value: must be specified when `operator` is 'In' or 'NotIn'

This changes the generated expression to use a different operator if no values are passed.

Which issue(s) this PR fixes:

xref kubermatic/kubermatic#11741

What type of PR is this?
/kind bug

Special notes for your reviewer:

Does this PR introduce a user-facing change? Then add your Release Note here:

Generate correct KubeVirt node affinity if no values for matching are passed

Documentation:

NONE

Signed-off-by: Marvin Beckers <marvin@kubermatic.com>
@kubermatic-bot kubermatic-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. docs/none Denotes a PR that doesn't need documentation (changes). kind/bug Categorizes issue or PR as related to a bug. dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. sig/virtualization Denotes a PR or issue as being assigned to SIG Virtualization. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 8, 2023
@hdurand0710
Copy link
Contributor

looks good but can you please add a unit test in provider_test.go(data in testdata folder) for this?

@embik
Copy link
Member Author

embik commented Feb 8, 2023

looks good but can you please add a unit test in provider_test.go(data in testdata folder) for this?

Sure, good point!

Signed-off-by: Marvin Beckers <marvin@kubermatic.com>
@kubermatic-bot kubermatic-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 8, 2023
Signed-off-by: Marvin Beckers <marvin@kubermatic.com>
@embik
Copy link
Member Author

embik commented Feb 8, 2023

/retest

Copy link
Contributor

@hdurand0710 hdurand0710 left a comment

Choose a reason for hiding this comment

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

/lgtm

@kubermatic-bot kubermatic-bot added the lgtm Indicates that a PR is ready to be merged. label Feb 8, 2023
@kubermatic-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 7c3f7402392d1aed994c8b7858b22fe1b9d1545b

@hdurand0710
Copy link
Contributor

/approve

@kubermatic-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: embik, hdurand0710

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

@kubermatic-bot kubermatic-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 8, 2023
@kubermatic-bot kubermatic-bot merged commit c175998 into kubermatic:main Feb 8, 2023
@embik embik deleted the kubevirt-affinity-fix branch February 8, 2023 12:45
@embik
Copy link
Member Author

embik commented Feb 8, 2023

/cherry-pick release/v1.55

@embik
Copy link
Member Author

embik commented Feb 8, 2023

/cherry-pick release/v1.45

@kubermatic-bot
Copy link
Contributor

@embik: #1557 failed to apply on top of branch "release/v1.55":

Applying: Generate correct node affinity if no values are passed
Using index info to reconstruct a base tree...
M	pkg/cloudprovider/provider/kubevirt/provider.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/cloudprovider/provider/kubevirt/provider.go
CONFLICT (content): Merge conflict in pkg/cloudprovider/provider/kubevirt/provider.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Generate correct node affinity if no values are passed
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release/v1.55

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.

@kubermatic-bot
Copy link
Contributor

@embik: #1557 failed to apply on top of branch "release/v1.45":

Applying: Generate correct node affinity if no values are passed
Using index info to reconstruct a base tree...
M	pkg/cloudprovider/provider/kubevirt/provider.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/cloudprovider/provider/kubevirt/provider.go
CONFLICT (content): Merge conflict in pkg/cloudprovider/provider/kubevirt/provider.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Generate correct node affinity if no values are passed
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release/v1.45

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.

@embik embik added the backport-needed Denotes a PR or issue that has not been fully backported. label Feb 8, 2023
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. backport-needed Denotes a PR or issue that has not been fully backported. dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. docs/none Denotes a PR that doesn't need documentation (changes). kind/bug Categorizes issue or PR as related to a bug. 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. sig/virtualization Denotes a PR or issue as being assigned to SIG Virtualization. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants