-
Notifications
You must be signed in to change notification settings - Fork 1.2k
✨ Backport release-0.5: Support metadata-only watches #1256
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
✨ Backport release-0.5: Support metadata-only watches #1256
Conversation
Add support for metadata-only watches. This backports a series of commits from the main branch: Add low-level metadata-only informer support This adds support for informers that communicate with the API server in metadata-only form. They are *completely* separate from normal informers -- that is: just like unstructured, if you ask for both a "normal" informer & a metadata-only informer, you'll get two copies of the cache. Support metadata-only client operations This adds support for a metadata-only client. It only implements the operations supported by metadata (delete, deleteallof, patch, get, list, status.patch). The higher-level client will now delegate to this for when a PartialObjectMetadata object is passed in. Support "projections" in the controller builder This adds options to "project" watches as only metadata to the builder, making it more convienient to use these forms. For instance: ```go .Owns(&corev1.Pod{}, builder.OnlyMetadata) ``` is equivalent to ```go .Owns(&metav1.PartialObjectMetadata{ TypeMeta: metav1.TypeMeta{ APIVersion: "v1", Kind: "Pod", }, }) ``` Co-authored-by: Solly Ross <[email protected]> Signed-off-by: Vince Prignano <[email protected]>
This change allows builders to use builder.OnlyMetadata when creating extra watches with .Watches(...). The code inspects the passed source.Source, and if it's of type *source.Kind, it calls the internal project method that allows to use metav1.PartialObjectMetadata in mapping functions. Signed-off-by: Vince Prignano <[email protected]> (cherry picked from commit df54dc5)
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, vincepri 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 |
/hold |
uuhhh, this retroactively makes the original PR and the other backport breaking, right? Namely, it's breaking because the |
chatted offline briefly, I think this is fine as long as we remember to also mark the corresponding changes in v0.6.4 and v0.7.0 as breaking instead (with a bit of an explanation as to what happened), since neither of those have been released yet. |
/hold cancel |
This PR backports the metadata only watches to the release-0.5 branch in a non breaking change. The API is a bit different and I had to have some workarounds to make it work, but it seems that it should fit nicely with the rest of it.
In particular, given the lack of Options for the builder For, Watches, and Owns, we support metadata-only types by encapsulating them in a custom internal type, which then gets projected to the actual type when the manager gets built.
/milestone v0.5.x
/assign @alvaroaleman @DirectXMan12 @ncdc