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

Vm controller copy fix #11265

Merged
merged 3 commits into from
Feb 16, 2024
Merged

Conversation

xpivarc
Copy link
Member

@xpivarc xpivarc commented Feb 15, 2024

What this PR does

Before this PR:
A cache is corrupted.

After this PR:
A cache is not corrupted ;)

Fixes #

Special notes for your reviewer

This is a suboptimal patch to be able to backport this for the latest releases.

Release note

Bug fix: VM controller doesn't corrupt its cache anymore

@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. size/L labels Feb 15, 2024
Copy link
Contributor

@jean-edouard jean-edouard left a comment

Choose a reason for hiding this comment

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

/approve
Just one nit. Also you pushed a modified example VM. Thank you!

@@ -333,6 +334,12 @@ var _ = Describe("VirtualMachine", func() {
mockQueue.Wait()
}

execute := func(vm *virtv1.VirtualMachine) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: the name execute() is confusing, since vm.go already has one. Maybe sanityExecute() or something like that would be a better name?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, thanks!

@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jean-edouard

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 Feb 15, 2024
This allow us to detect if a given
VM struct is being modified by Execute.

Signed-off-by: Luboslav Pivarc <lpivarc@redhat.com>
cache.Store is returning a pointer to stored
struct. Any modification of the struct is therefore
reflected in the underlying store. This can cause
issues when a loop changes something but the
update call fails.

Signed-off-by: Luboslav Pivarc <lpivarc@redhat.com>
These tests are relying on a fact that
a cached object is being modified

Signed-off-by: Luboslav Pivarc <lpivarc@redhat.com>
@xpivarc
Copy link
Member Author

xpivarc commented Feb 15, 2024

/cherry-pick release-1.2
/cherry-pick release-1.1
/cherry-pick release-1.0
/cherry-pick release-0.59

@kubevirt-bot
Copy link
Contributor

@xpivarc: once the present PR merges, I will cherry-pick it on top of release-1.2 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.2
/cherry-pick release-1.1
/cherry-pick release-1.0
/cherry-pick release-0.59

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.

@@ -297,6 +297,7 @@ func (c *VMController) execute(key string) error {
return nil
}
vm := obj.(*virtv1.VirtualMachine)
vm = vm.DeepCopy()
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious: where was the actual cache corruption? I tried to track it and the code below seems to do deep copy where needed. But maybe I missed that...

Copy link
Member Author

Choose a reason for hiding this comment

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

https://github.com/kubevirt/kubevirt/blob/main/pkg/virt-controller/watch/vm.go#L2923-L2940

I think there was one or two more. Anyway, there are additional bugs, will post PRs tomorrow :)

Copy link
Contributor

Choose a reason for hiding this comment

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

indeed. nice catch 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah right, should have looked at my notes better... They do it but they do not need to. I will post a patch for it.

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Feb 15, 2024
@kubevirt-commenter-bot
Copy link

Required labels detected, running phase 2 presubmits:
/test pull-kubevirt-e2e-windows2016
/test pull-kubevirt-e2e-kind-1.27-vgpu
/test pull-kubevirt-e2e-kind-sriov
/test pull-kubevirt-e2e-k8s-1.29-ipv6-sig-network
/test pull-kubevirt-e2e-k8s-1.27-sig-network
/test pull-kubevirt-e2e-k8s-1.27-sig-storage
/test pull-kubevirt-e2e-k8s-1.27-sig-compute
/test pull-kubevirt-e2e-k8s-1.27-sig-operator
/test pull-kubevirt-e2e-k8s-1.28-sig-network
/test pull-kubevirt-e2e-k8s-1.28-sig-storage
/test pull-kubevirt-e2e-k8s-1.28-sig-compute
/test pull-kubevirt-e2e-k8s-1.28-sig-operator

@kubevirt-bot
Copy link
Contributor

@xpivarc: The following tests 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-e2e-k8s-1.28-sig-compute a3060dd link unknown /test pull-kubevirt-e2e-k8s-1.28-sig-compute
pull-kubevirt-e2e-k8s-1.27-sig-storage a3060dd link unknown /test pull-kubevirt-e2e-k8s-1.27-sig-storage

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.

@kubevirt-bot kubevirt-bot merged commit 9a79118 into kubevirt:main Feb 16, 2024
35 of 37 checks passed
@kubevirt-bot
Copy link
Contributor

@xpivarc: #11265 failed to apply on top of branch "release-1.1":

Applying: Unit test: Wrap controller.Execute
Using index info to reconstruct a base tree...
M	pkg/virt-controller/watch/vm_test.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/virt-controller/watch/vm_test.go
CONFLICT (content): Merge conflict in pkg/virt-controller/watch/vm_test.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 Unit test: Wrap controller.Execute
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-1.2
/cherry-pick release-1.1
/cherry-pick release-1.0
/cherry-pick release-0.59

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.

@kubevirt-bot
Copy link
Contributor

@xpivarc: #11265 failed to apply on top of branch "release-1.0":

Applying: Unit test: Wrap controller.Execute
Using index info to reconstruct a base tree...
M	pkg/virt-controller/watch/vm_test.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/virt-controller/watch/vm_test.go
CONFLICT (content): Merge conflict in pkg/virt-controller/watch/vm_test.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 Unit test: Wrap controller.Execute
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-1.2
/cherry-pick release-1.1
/cherry-pick release-1.0
/cherry-pick release-0.59

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.

@kubevirt-bot
Copy link
Contributor

@xpivarc: #11265 failed to apply on top of branch "release-0.59":

Applying: Unit test: Wrap controller.Execute
Using index info to reconstruct a base tree...
M	pkg/virt-controller/watch/vm_test.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/virt-controller/watch/vm_test.go
CONFLICT (content): Merge conflict in pkg/virt-controller/watch/vm_test.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 Unit test: Wrap controller.Execute
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-1.2
/cherry-pick release-1.1
/cherry-pick release-1.0
/cherry-pick release-0.59

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.

@kubevirt-bot
Copy link
Contributor

@xpivarc: new pull request created: #11271

In response to this:

/cherry-pick release-1.2
/cherry-pick release-1.1
/cherry-pick release-1.0
/cherry-pick release-0.59

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

5 participants