-
Notifications
You must be signed in to change notification settings - Fork 39.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
Don't clear managedFields on live object #106195
Don't clear managedFields on live object #106195
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
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. |
Welcome @alexzielenski! |
Hi @alexzielenski. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
6111b38
to
faa63cc
Compare
faa63cc
to
ef6d440
Compare
/assign |
Thank you Alex, that's great! A quick note on an inaccuracy in the description:
Clients don't have direct references, but there can be webhooks (third-party processes that can see the modifications happening on the cluster) that receives a copy of the live object and the new object. Because of this bug, they receive an incorrect version of the live object. |
/ok-to-test |
@@ -80,7 +81,8 @@ func (f *managedFieldsUpdater) Apply(liveObj, appliedObj runtime.Object, managed | |||
managed.Times()[fieldManager] = &metav1.Time{Time: time.Now().UTC()} | |||
} | |||
if object == nil { | |||
object = liveObj | |||
object = liveObj.DeepCopyObject() | |||
internal.RemoveObjectManagedFields(object) |
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.
I can't see a test that verifies that use-case? object == nil
means that the object hasn't changed at all. I think if you apply the same object twice, that would happen.
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.
This line is exercised here:
kubernetes/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/fieldmanager_test.go
Line 1374 in 0963704
if err := f.Apply(newObj, "fieldmanager_z", false); err != nil { |
I just manually verified that it is hit. I'm wondering if you know of a better way to make the connection between the test and that line's coverage explicit? Currently the test only checks that liveObj
is unchanged.
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.
You maybe need to write a more targeted unit-test, probably in https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/managedfieldsupdater_test.go
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.
we want a test that not only hits this line, but if possible, would fail without the deepcopy and dropping managed fields
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.
Yeah, but this line is basically completely pointless because FieldManager
always replaces it anyway
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.
If we want to test that it's being reset, we need to test without the FieldManager
.
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.
I've pushed my attempt to address the above feedback in 92aa3c5 please take a look. This commit has a test which adds a node at the end of the manager pipeline, but before FieldManager
, so that we can directly test if the liveObj
has been copied, and its managedFields removed.
99fd439
to
92aa3c5
Compare
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.
/lgtm
/approve
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/managedfieldsupdater_test.go
Outdated
Show resolved
Hide resolved
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alexzielenski, apelisse 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 |
92aa3c5
to
efa31d6
Compare
gofmt is a legit error, I'll re-lgtm once fixed, thanks! |
addresses feedback by adding a test to make sure that the manager pipeline will not return the same instance used as input, and that the output does not input managedFields
efa31d6
to
68e175e
Compare
/lgtm |
/hold cancel |
Seems like this test is not deterministic? |
/retest |
Yeah, if you have patience, you can find out who wrote/modified that test and open a ticket for the flake. cc @liggitt |
cc @jingxu97 on flake in Test_Run_OneVolumeDetachFailNodeWithReadWriteOnce |
The Kubernetes project has merge-blocking tests that are currently too flaky to consistently pass. This bot retests PRs for certain kubernetes repos according to the following rules:
You can:
/retest |
3 similar comments
The Kubernetes project has merge-blocking tests that are currently too flaky to consistently pass. This bot retests PRs for certain kubernetes repos according to the following rules:
You can:
/retest |
The Kubernetes project has merge-blocking tests that are currently too flaky to consistently pass. This bot retests PRs for certain kubernetes repos according to the following rules:
You can:
/retest |
The Kubernetes project has merge-blocking tests that are currently too flaky to consistently pass. This bot retests PRs for certain kubernetes repos according to the following rules:
You can:
/retest |
/hold
/kind bug
Fixes a bug wherein the managedFields of the
liveObject
are altered with calls to Update/Apply. This is problematic because there may be webhooks which expect to receive change notifications with a copy of the old object and the new object. Changes to the live object can cause the notification to be inaccurate.This patch adds a test to make sure that the liveObject instance returned by a call to
FieldManager.Apply
has itsmanagedFields
metadata intact after another call toFieldManager.Apply
.Also adds two tests to check that managedFields is unaltered (order, timestamp) when a configuration is applied which should lead to a noop. (For both Apply & Update code paths).