Skip to content

Add new dynamic fake that supports server-side apply / field managers #76

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ecordell
Copy link
Contributor

@ecordell ecordell commented Jul 1, 2025

This mimics the upstream dynamic fake but supports server-side apply semantics.

There are two main parts of this that are working around two separate issues in the upstream client:

  1. Supporting field management. This pulls in very new versions of apimachinery and client-go to get the FieldManagedObjectTracker, which is a test object tracker that supports field management. I ran into a lot of issues when trying to wire it into the client directly, and finally settled on the implementation here: two trackers are used, one that intercepts patch requests and does server-side apply logic, and one that handles everything else. Once server-side apply logic has run, the object is forwarded to the "upstream" object tracker. I think this could be better implemented directly upstream, but for now I just wanted something I could use.

  2. Supporting merge semantics. Once I got SSA generally supported (i.e. create-via-apply, etc) in the fake with the object tracker, proper merge semantics still weren't working - all lists were being treated as atomic, for example. This seems to be an issue with the upstream fakes as well, though I didn't confirm. To work around it, this ships its own copy of the kube openapi schema that it uses to properly support list merging. You also need to pass in any CRD definitions you want merge support for, for the same reason.

The end result is a dynamic fake with the same / similar API as the upstream one but which supports SSA semantics properly.

@ecordell ecordell force-pushed the dynfake branch 3 times, most recently from d04bca1 to cd2e3c4 Compare July 1, 2025 19:18
Copy link

@Verolop Verolop left a comment

Choose a reason for hiding this comment

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

this is great! The main changes look good, except a potential bug in DryRun. See comments.

@ecordell ecordell force-pushed the dynfake branch 2 times, most recently from a249507 to c64c9e9 Compare July 2, 2025 13:08
this mimics the upstream dynamic fake but supports server-side apply
semantics
Also updates the (fake pkg) readme to be more concise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants