Skip to content
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

✨ Fakeclient: Add apply support #2981

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alvaroaleman
Copy link
Member

@alvaroaleman alvaroaleman commented Oct 14, 2024

I don't think this change should be merged, but leaving it here for future reference before I forget about it.

Ref #2341

This change is a POC for adding apply patch support to the fake client.

This relies on the upstream support for this which is implemented in a new FieldManagedObjectTracker. There are two major problems with this for us though:

  1. It requires a type converter which gets initialized with a parser that knows how the type look like. It doesn't look like it is possible to pass multiple parsers, which means the resulting client can only deal with the set of types the parser knows about, for example what is in client-go but it will not work with CRDs
  2. We have some code that wants to look at the object after it was patched to check if its valid - Since this is implemented in the tracker, it doesn't look like its possible to dry run the patch

This change is a POC for adding apply patch support to the fake client.

This relies on the upstream support for this which is implemented in a
new [FieldManagedObjectTracker][0]. There are two major problems with
this for us though:
1. It requires a [type converter][1] which gets initialized with a
   [parser][2] that knows how the type look like. It doesn't look like
   it is possible to pass multiple parsers, which means the resulting
   client can only deals with the set of types the parser knows about,
   for example what is in client-go but it will not work with CRDs
2. We have some code that wants to look at the object after it was
   patched to check if its valid - Since this is implemented in the
   tracker, it doesn't look like its possible to dry run the patch

[0]: https://github.com/kubernetes/kubernetes/blob/4dc7a48ac6fb631a84e1974772bf7b8fd0bb9c59/staging/src/k8s.io/client-go/testing/fixture.go#L643
[1]: https://github.com/kubernetes/kubernetes/blob/4dc7a48ac6fb631a84e1974772bf7b8fd0bb9c59/staging/src/k8s.io/client-go/applyconfigurations/utils.go#L1739
[2]: https://github.com/kubernetes/kubernetes/blob/4dc7a48ac6fb631a84e1974772bf7b8fd0bb9c59/staging/src/k8s.io/client-go/applyconfigurations/internal/internal.go#L28
@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 14, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 14, 2024
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 14, 2024
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 10, 2024
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants