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

handler,predicate: pause object reconciliation by annotation #60

Merged
merged 2 commits into from
Jul 23, 2021
Merged

Conversation

estroz
Copy link
Member

@estroz estroz commented May 25, 2021

Description of the change: added NewPause(key) to handler and predicate packages that returns an EventHandler and Predicate, respectively, to pause object reconciliation on objects with the <key>: true annotation.

Motivation for the change: something along the lines of operator-framework/operator-sdk#3418.

/kind feature

@openshift-ci openshift-ci bot added the kind/feature Categorizes issue or PR as related to a new feature. label May 25, 2021
@estroz
Copy link
Member Author

estroz commented May 25, 2021

The tests added here break other handler tests because they share the same metrics registry. If this POC is accepted, the author (me or someone else) will re-write the tests so they do not affect each other.

@estroz
Copy link
Member Author

estroz commented May 25, 2021

/cc @varshaprasad96 @jmrodri

@coveralls
Copy link

coveralls commented Jun 7, 2021

Pull Request Test Coverage Report for Build 1049826637

  • 99 of 114 (86.84%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+1.6%) to 80.827%

Changes Missing Coverage Covered Lines Changed/Added Lines %
handler/pause.go 0 3 0.0%
predicate/pause.go 0 3 0.0%
internal/annotation/filter.go 99 108 91.67%
Totals Coverage Status
Change from base Build 1008827874: 1.6%
Covered Lines: 430
Relevant Lines: 532

💛 - Coveralls

// the controller will see events from these objects again.
type filter struct {
key string
ret bool
Copy link
Member

Choose a reason for hiding this comment

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

Non-blocking thought:

It might be generally useful to add a Not(in predicate.Predicate) predicate.Predicate wrapper in C-R that inverts the logic of the input predicate.

If that existed, would you need the ret field?

I alluded to this in the C-R PR where I added the Or and And wrappers here, but I never added it because there hasn't been a use case for it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think you'd need ret here in that case. Given that operator-lib is pre v1.0, are you ok with adding this as-is now then removing if Not is added to c-r?

@estroz
Copy link
Member Author

estroz commented Jun 8, 2021

@joelanford given that Falsy/Truthy filters are complements, yes Not() would be useful here.

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 19, 2021
by event handler or predicate via an annotation with key
string key, respectively

internal/annotation: add generic library for creating
predicates and event handlers for arbitrary annotation keys

Signed-off-by: Eric Stroczynski <ericstroczynski@gmail.com>
Signed-off-by: Eric Stroczynski <ericstroczynski@gmail.com>
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 20, 2021
@estroz estroz changed the title [POC] handler,predicate: pause object reconciliation by annotation handler,predicate: pause object reconciliation by annotation Jul 20, 2021
Copy link
Member

@jmrodri jmrodri 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 openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 23, 2021
@estroz
Copy link
Member Author

estroz commented Jul 23, 2021

Not sure why it's not marking this automatically approved. @jmrodri can you /approve too?

@varshaprasad96
Copy link
Member

/approve

@openshift-ci
Copy link

openshift-ci bot commented Jul 23, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: varshaprasad96

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

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. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants