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

✨ Backport support for metadata-only watches to release-0.6 #1248

Merged

Conversation

ncdc
Copy link
Contributor

@ncdc ncdc commented Nov 5, 2020

Add support for metadata-only watches to release-0.6. Note, this was a manual backport, as there were several conflicts when trying to cherry-pick. All the tests should be passing, but I encourage reviewers to 👀 carefully. Thanks!

From the original PRs:

#1174:
This introduces metadata-only support (PartialObjectMetadata) to the client, cache, and controller builder. It works much like unstructured does, with an end-use of:

.Owns(&corev1.Pod{}, builder.OnlyMetadata)
// or
.Owns(&metav1.PartialObjectMetadata{/* GVK for corev1.Pod filled out here */})

// ...

var pods metav1.PartialObjectMetadataList
pods.SetGroupVersionKind(corev1.SchemeGroupVersion.WithKind("PodList"))
cl.List(ctx, &pods, client.MatchingLabels{...})

Note that like unstructured, the caches are completely separate -- asking for an unstructured object or concrete object will end up constructing a separate cache.

#1242:
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.

Fixes #1236

ncdc and others added 2 commits November 5, 2020 15:16
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 <sollyross@google.com>
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 <vincepri@vmware.com>
(cherry picked from commit df54dc5)
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 5, 2020
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Nov 5, 2020
@vincepri vincepri added this to the v0.6.x milestone Nov 5, 2020
@ncdc
Copy link
Contributor Author

ncdc commented Nov 5, 2020

I copied over all the changes in the main branch in pkg/client/client_test.go, which appeared to delete a bunch of patch-related tests (or maybe they're covered elsewhere?). Not sure if that's appropriate for 0.6 - please let me know.

Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/approve
/assign @alvaroaleman

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 9, 2020
Copy link
Member

@alvaroaleman alvaroaleman left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 9, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman, ncdc, 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:
  • OWNERS [alvaroaleman,vincepri]

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 merged commit 7fc9110 into kubernetes-sigs:release-0.6 Nov 9, 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.

None yet

4 participants