Skip to content

Update hander/enqueue_annotation.go#2

Merged
varshaprasad96 merged 4 commits intooperator-framework:mainfrom
varshaprasad96:annotations/watch-resources
Jul 23, 2020
Merged

Update hander/enqueue_annotation.go#2
varshaprasad96 merged 4 commits intooperator-framework:mainfrom
varshaprasad96:annotations/watch-resources

Conversation

@varshaprasad96
Copy link
Copy Markdown
Member

This commit updates the implementation in enqueue_annotation, to
watch dependent resources based on the presence of an annotation.

Motivation: (Taken from PR #892 of Controller Runtime)

While owner references are the idiomatic way to manage dependent resources, they don't solve all use cases. Owner references have restrictions that limit which objects can own other objects.

An annotation-based watch handler does not have these restrictions. However, they don't provide the same feature set either.

The watch handler can be used to trigger reconciliation of a parent resource based on changes to dependent resources that include an annotation. The purpose of this handler is to support cross-scope ownership relationships that are not supported by native owner references.

For example, owner references are used for garbage collection. If a resource's owner is deleted, the resource will also be deleted. Because of this, annotation references need to be paired with a finalizer so that the operator can manually garbage collect.

Co-Authored-by: Camila Macedo cmacedo@redhat.com

Comment thread handler/enqueue_annotation.go Outdated
Comment thread go.mod Outdated
Comment thread handler/enqueue_annotation.go Outdated
Comment thread handler/enqueue_annotation.go Outdated
// SetWatchOwnerAnnotation is a helper method to add watch annotation-based with the owner NamespacedName and
// schema.GroupKind to the object provided. This allows you to declare the watch annotations of an owner to an object.
// If a annotation to the same object already exists, it'll be overwritten with the newly provided version.
func SetOwnerAnnotation(owner, object metav1.Object, ownerGK schema.GroupKind) error {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

See that it is a helper. so, we need to update the places in SDK that are using the annotation.

Copy link
Copy Markdown
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

This PR kubernetes-sigs/controller-runtime#892 received a lot of contributions from the devs in the controller-runtime. So, I think it is in good shape. What is missing to do here;

  • Cleanup the go mod
  • Update the places across the project to use the helper
  • We need to check the CI. (lint to ensure that all is fine, test to check if these tests are ok, ansible and helm as well to check that nothing broke after that and all is properly updated)

@varshaprasad96 varshaprasad96 force-pushed the annotations/watch-resources branch from 2726c3e to 4ba30c9 Compare July 21, 2020 20:22
Copy link
Copy Markdown
Member

@joelanford joelanford left a comment

Choose a reason for hiding this comment

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

Unit tests pass for me once I remove the unnecessary dependency on running envtest. However, given all the nits and discrepancies I found, I'm a little concerned with the validity of the tests.

Let's make sure to double/triple check everything before we merge.

Comment thread go.mod Outdated
Comment thread handler/enqueue_annotation.go Outdated
Comment thread handler/enqueue_annotation.go Outdated
Comment thread handler/enqueue_annotation.go Outdated
Comment thread handler/enqueue_annotation.go Outdated
Comment thread handler/enqueue_annotation_test.go Outdated
Comment thread handler/enqueue_annotation_suite_test.go Outdated
Comment thread handler/enqueue_annotation_suite_test.go
Comment thread handler/enqueue_annotation_suite_test.go Outdated
Comment thread handler/enqueue_annotation_test.go Outdated
@jmrodri jmrodri changed the base branch from master to main July 21, 2020 22:02
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 22, 2020
@varshaprasad96 varshaprasad96 force-pushed the annotations/watch-resources branch from 7b3c512 to 2a45e4d Compare July 22, 2020 18:46
varshaprasad96 and others added 3 commits July 22, 2020 11:55
This commit updates the implementation in enqueue_annotation, to
watch dependent resources based on the presence of an annotation
on them.

Co-Authored-by: Camila Macedo <cmacedo@redhat.com>
@varshaprasad96 varshaprasad96 force-pushed the annotations/watch-resources branch from 2a45e4d to f03d3a7 Compare July 22, 2020 18:55
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 22, 2020
@varshaprasad96 varshaprasad96 force-pushed the annotations/watch-resources branch 3 times, most recently from 5835cd5 to c15d42b Compare July 22, 2020 19:04
@varshaprasad96
Copy link
Copy Markdown
Member Author

varshaprasad96 commented Jul 22, 2020

Addressed review comments, and made changes to the PR.

Comment thread handler/enqueue_annotation.go Outdated
@varshaprasad96 varshaprasad96 force-pushed the annotations/watch-resources branch from c15d42b to 2d6fca2 Compare July 22, 2020 19:22
@coveralls
Copy link
Copy Markdown

coveralls commented Jul 22, 2020

Pull Request Test Coverage Report for Build 180371929

  • 29 of 29 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 178609315: 0.0%
Covered Lines: 134
Relevant Lines: 134

💛 - Coveralls

Copy link
Copy Markdown
Member

@estroz estroz left a comment

Choose a reason for hiding this comment

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

Mostly nits and grammar, looks great otherwise.

Comment thread handler/enqueue_annotation.go Outdated
Comment thread handler/enqueue_annotation.go Outdated
Comment thread handler/enqueue_annotation.go Outdated
Comment thread handler/enqueue_annotation.go Outdated
Comment thread handler/enqueue_annotation.go Outdated
Comment thread handler/enqueue_annotation.go Outdated
Comment thread handler/enqueue_annotation.go
Comment thread handler/enqueue_annotation.go Outdated
Comment thread handler/enqueue_annotation.go Outdated
Comment thread handler/enqueue_annotation.go Outdated
@varshaprasad96 varshaprasad96 force-pushed the annotations/watch-resources branch from 2d6fca2 to b9bbc70 Compare July 22, 2020 21:17
@varshaprasad96 varshaprasad96 requested a review from estroz July 22, 2020 21:33
@varshaprasad96 varshaprasad96 force-pushed the annotations/watch-resources branch from b9bbc70 to 9d29dbd Compare July 22, 2020 21:54
Comment thread handler/enqueue_annotation.go Outdated
Comment thread handler/enqueue_annotation.go Outdated
Comment thread handler/handler_test.go Outdated
Comment thread handler/handler_test.go Outdated
Comment thread handler/handler_test.go Outdated
Comment thread handler/handler_test.go Outdated
Comment thread handler/handler_test.go
Comment thread handler/handler_test.go Outdated
@varshaprasad96 varshaprasad96 force-pushed the annotations/watch-resources branch 2 times, most recently from ce9b384 to 5be29f3 Compare July 23, 2020 16:36
Copy link
Copy Markdown
Member

@joelanford joelanford left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 23, 2020
Copy link
Copy Markdown
Member

@estroz estroz left a comment

Choose a reason for hiding this comment

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

/lgtm

@varshaprasad96 varshaprasad96 force-pushed the annotations/watch-resources branch from 5be29f3 to bc589e5 Compare July 23, 2020 21:13
@openshift-ci-robot
Copy link
Copy Markdown

New changes are detected. LGTM label has been removed.

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Jul 23, 2020
@varshaprasad96 varshaprasad96 merged commit 525cb9a into operator-framework:main Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants