-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Vm controller copy fix #11265
Conversation
There was a problem hiding this 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!
pkg/virt-controller/watch/vm_test.go
Outdated
@@ -333,6 +334,12 @@ var _ = Describe("VirtualMachine", func() { | |||
mockQueue.Wait() | |||
} | |||
|
|||
execute := func(vm *virtv1.VirtualMachine) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks!
[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 |
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>
6e9422f
to
a3060dd
Compare
/cherry-pick release-1.2 |
@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:
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() |
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed. nice catch 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vasiliy-ul Here as well. https://github.com/kubevirt/kubevirt/blob/main/pkg/virt-controller/watch/vm.go#L875
👍
https://github.com/kubevirt/kubevirt/blob/main/pkg/virt-controller/watch/vm.go#L2944 https://github.com/kubevirt/kubevirt/blob/main/pkg/virt-controller/watch/vm.go#L2957
c.removeVMFinalizer
and c.addVMFinalizer
do a deep copy internally.
There was a problem hiding this comment.
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.
Required labels detected, running phase 2 presubmits: |
@xpivarc: The following tests failed, say
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. |
@xpivarc: #11265 failed to apply on top of branch "release-1.1":
In response to this:
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. |
@xpivarc: #11265 failed to apply on top of branch "release-1.0":
In response to this:
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. |
@xpivarc: #11265 failed to apply on top of branch "release-0.59":
In response to this:
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. |
@xpivarc: new pull request created: #11271 In response to this:
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. |
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