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
Update managedFields time when field value is modified #110058
Conversation
Hi @glebiller. 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. |
/assign @apelisse |
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 left a comment, can you also double-check that the behavior with Apply
is consistent?
Thank you for working on this!
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/managedfieldsupdater.go
Outdated
Show resolved
Hide resolved
Thanks for working on this! |
455bf7c
to
e2b3c97
Compare
Following the feedback, I simplified the code and added the following unit tests for both apply & update:
For UpdateIt looks like For ApplyThe server-side-apply seems to be functional during my test in a live cluster. With the unit tests, I noticed that the Note for the reviewerI notice that in the unit test TestNonManagedFieldsUpdateDoesNotModifyTime, after the third Update, the ManagedFields only have the fields from one manager ( The Apply behavior is different, as the third Apply correctly returns the ManagedFields for both managers with the time changed accordingly. |
/triage accepted |
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.
One thing that we have in the doc but isn't tested here, is that when a field is removed from a set (because it's stolen by someone else), that set's timestamp doesn't change, i.e.
In mostly pseudo-code:
applyObject("managerA", `{fieldA: true, fieldB: true}`)
time.Sleep(1)
applyObject("managerB", `{fieldA: false}`)
// Check that managerA timestamp hasn't changed.
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/managedfieldsupdater.go
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/managedfieldsupdater_test.go
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/managedfieldsupdater_test.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/managedfieldsupdater_test.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/managedfieldsupdater_test.go
Outdated
Show resolved
Hide resolved
According to the Server-Side-Apply doc, this is not possible because it raises a conflict error. I tried creating a unit test for that case, but I got the following error: The use case that could be tested, is during the Update instead of Apply. |
e2b3c97
to
cd41a92
Compare
There is a "Force" field to steal ownership with |
Thanks, LGTM once you add the |
cd41a92
to
f681821
Compare
That's on me, I should have thought about the force as it's similar to the kubectl command line :) |
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/managedfieldsupdater_test.go
Show resolved
Hide resolved
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
Thanks!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: apelisse, glebiller 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 |
Thanks! |
What type of PR is this?
/kind bug
What this PR does / why we need it:
The
managedFields.time
is not updated if only the value of a managed field is changed during apply. According to the doc, the time field should be updated during creation, when a field is added or removed, or when a field value is changed.This PR detects if a managed field has been modified and updates the time accordingly.
Which issue(s) this PR fixes:
Fixes #109576
Special notes for your reviewer:
I had to remove the unit test validating that when a non-managed field is updated, the time is not changed. It seems impossible to validate that we either have a conflict exception if a non-managed field is updated or the time should be updated.
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: