Skip to content

🐛 fakeclient: Allow updating managedFields through Update#3485

Open
metlos wants to merge 1 commit intokubernetes-sigs:mainfrom
metlos:update-managed-fields
Open

🐛 fakeclient: Allow updating managedFields through Update#3485
metlos wants to merge 1 commit intokubernetes-sigs:mainfrom
metlos:update-managed-fields

Conversation

@metlos
Copy link
Copy Markdown

@metlos metlos commented Mar 25, 2026

The managed fields could not be explicitly modified in Update or merge Patch in the fake client.

This is explicitly allowed and sometimes even necessary (e.g. upgrade from CSA to SSA) and so the fake client should support this.

Also, I think the handling of managed fields on subresources in general (apart from status) is not well supported yet, so I took the liberty of adding a pending test for that (and am happy to remove it if you don't want it as part of this PR).

This fixes #3484.

or merge Patch in the fake client.

This is explicitly allowed and sometimes even necessary (e.g. upgrade
from CSA to SSA) and so the fake client should support this.
@k8s-ci-robot k8s-ci-robot requested a review from JoelSpeed March 25, 2026 23:40
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: metlos
Once this PR has been reviewed and has the lgtm label, please assign joelanford for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details 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

@k8s-ci-robot k8s-ci-robot requested a review from vincepri March 25, 2026 23:40
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Mar 25, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: metlos / name: Lukas Krejci (733a8ad)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Mar 25, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Welcome @metlos!

It looks like this is your first PR to kubernetes-sigs/controller-runtime 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/controller-runtime has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 25, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @metlos. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Mar 25, 2026
@sbueringer
Copy link
Copy Markdown
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 31, 2026
})

// this is not working properly and can't without a larger change to the codebase
PIt("should not be able to manually update the managed fields through a subresource create,update", func(ctx SpecContext) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So this is a regression?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

No, not a regression. I think this never really worked and I'm not 100% sure about the full extent of changes that would make this work (e.g. the special handling of the scale subresource in update, ...). That's why I asked in the issue description if you even want this test in this PR.

@metlos
Copy link
Copy Markdown
Author

metlos commented Mar 31, 2026

/retest

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@metlos: The following test 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-controller-runtime-test 733a8ad link true /test pull-controller-runtime-test

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

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-sigs/prow repository. I understand the commands that are listed here.

})

// GH-3484
It("respects the ManagedFields during create, update, merge patch", func(ctx SpecContext) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please write a testcase per operation

})

// this is not working properly and can't without a larger change to the codebase
PIt("should not be able to manually update the managed fields through a subresource create,update", func(ctx SpecContext) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This test is extremely confusing and tests two distinct things. It doesn't actually test that scale requests can not manipulate the objects managed fields, it tests that objects managed fields account correctly for scale, which is a different thing.

Please write a test instead that validates that setting managed fields on a scale request does not result in a change of the objects managed fields.

@@ -59,6 +59,7 @@ import (
const (
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is a compile failure in here

@alvaroaleman
Copy link
Copy Markdown
Member

/retitle 🐛 fakeclient: Allow updating managedFields through Update

@k8s-ci-robot k8s-ci-robot changed the title 🐛 The managed fields could not be explicitly modified in Update 🐛 fakeclient: Allow updating managedFields through Update Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

Fake client: ManagedFields modified using csaupgrade.UpgradeManagedFields are not persisted correctly

4 participants