Skip to content

✨ 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

Merged

Conversation

vincepri
Copy link
Member

@vincepri vincepri commented Nov 10, 2020

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

ncdc and others added 2 commits November 9, 2020 16:15
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)
@k8s-ci-robot k8s-ci-robot added this to the v0.5.x milestone Nov 10, 2020
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 10, 2020
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 10, 2020
@vincepri vincepri changed the title Backport release-0.5: Support metadata-only watches ✨ Backport release-0.5: Support metadata-only watches Nov 10, 2020
@k8s-ci-robot
Copy link
Contributor

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

@DirectXMan12
Copy link
Contributor

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 19, 2020
@DirectXMan12
Copy link
Contributor

DirectXMan12 commented Nov 19, 2020

uuhhh, this retroactively makes the original PR and the other backport breaking, right?
As funny as that'd be (think of all the time travel memes we could post!), I think it's probably not a great idea :-P

Namely, it's breaking because the OnlyMetadata type disappears in the future.

@DirectXMan12
Copy link
Contributor

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.

@DirectXMan12
Copy link
Contributor

/hold cancel
/lgtm

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Nov 19, 2020
@k8s-ci-robot k8s-ci-robot merged commit e1a1cae into kubernetes-sigs:release-0.5 Nov 19, 2020
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants