controller-runtime
controller-runtime copied to clipboard
:sparkles: Fakeclient: Add apply support
I don't think this change should be merged, but leaving it here for future reference before I forget about it.
Ref https://github.com/kubernetes-sigs/controller-runtime/issues/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:
- 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
- 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
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
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.
This bot triages PRs according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the PR is closed
You can:
- Mark this PR as fresh with
/remove-lifecycle stale - Close this PR with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
/lifecycle frozen This is a requested feature so I'd like to keep this open to demonstrate the challenges. I personally will not be working further on it though.
@alvaroaleman: The lifecycle/frozen label cannot be applied to Pull Requests.
In response to this:
/lifecycle frozen This is a requested feature so I'd like to keep this open to demonstrate the challenges. I personally will not be working further on it though.
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.
The lifecycle/frozen label can not be applied to PRs.
This bot removes lifecycle/frozen from PRs because:
- Commenting
/lifecycle frozenon a PR has not worked since March 2021 - PRs that remain open for >150 days are unlikely to be easily rebased
You can:
- Rebase this PR and attempt to get it merged
- Close this PR with
/close
Please send feedback to sig-contributor-experience at kubernetes/community.
/remove-lifecycle frozen
The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs.
This bot triages PRs according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the PR is closed
You can:
- Mark this PR as fresh with
/remove-lifecycle rotten - Close this PR with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten
@alvaroaleman I ran into this myself but was able to verify that this PR solves it well enough for my own needs at least.
Is there anything I can do to help land this in a release?
@tomasaschan this can not be merged in its current form, we need support in the upstream tracker for reloading the scheme and find a way to avoid breaking everyone by adding the managed fields.
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages PRs according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the PR is closed
You can:
- Reopen this PR with
/reopen - Mark this PR as fresh with
/remove-lifecycle rotten - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/close
@k8s-triage-robot: Closed this PR.
In response to this:
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages PRs according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied- After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied- After 30d of inactivity since
lifecycle/rottenwas applied, the PR is closedYou can:
- Reopen this PR with
/reopen- Mark this PR as fresh with
/remove-lifecycle rotten- Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/close
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.
@fsommar I think there's an old (probably closed PR, or intermediate step later refactored away) attempt at using this to test repo-enabler, if you're curious to test it on a "live" code base.
@fsommar I think there's an old (probably closed PR, or intermediate step later refactored away) attempt at using this to test repo-enabler, if you're curious to test it on a "live" code base.
I found usages of client-go fakes in an old immutator commit 759c336c833e420e0b0ff33dc5f06229540b88b7 on PR#20 fwiw, but not controller-runtime fakes. IIRC you tried controller-runtime fakes first and decided to pivot to use client-go, which had the same issue in the end (I can't find those first attempts in a pushed commit). And now it's using envtest.
We have some upcoming work using controller-runtime likely in July. I'll try it out then, as I have a short vacation first!
Here's the corresponding client-go fake issue, for reference: https://github.com/kubernetes/kubernetes/issues/133549
Nice! Thx for working on this.
My comments are mostly around improving test coverage and godoc a bit
@tomasaschan @fsommar could you please find a different place for your comments that are not about feedback to the code changes in here to avoid polluting this? Thanks!
@alvaroaleman Last one from my side: https://github.com/kubernetes-sigs/controller-runtime/pull/2981#discussion_r2169194034
/lgtm /approve
LGTM label has been added.
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: alvaroaleman, sbueringer
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~OWNERS~~ [alvaroaleman,sbueringer]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment