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

Add conditions.Factory #58

Merged

Conversation

joelanford
Copy link
Member

Description of the change:
Add conditions.Factory

Motivation for the change:
The conditions.NewCondition function reads cluster state to determine
the namespace the operator is running in so that it can manipulate the
correct OperatorConditions object in a cluster.

However this function's dependency on a specific file existing in a
specific location makes it difficult to test code that uses it.

The Factory struct is introduced to enable users to provide their own
implementations for looking up the name and namespace of the operator's
OperatorCondition object. Users can now build a factory and inject it into
code that builds new conditions. This enables code under test to use the
Factory abstraction and enables operator authors to inject custom
functionality needed when writing tests.

Closes #50

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please ask for approval from joelanford after the PR has been reviewed.

The full list of commands accepted by this bot can be found 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

@coveralls
Copy link

coveralls commented Apr 20, 2021

Pull Request Test Coverage Report for Build 1219544249

  • 38 of 38 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.7%) to 82.014%

Totals Coverage Status
Change from base Build 1186598825: 0.7%
Covered Lines: 456
Relevant Lines: 556

💛 - Coveralls

@joelanford joelanford force-pushed the conditions-factory branch 2 times, most recently from cf980c8 to 8ad7a7a Compare April 20, 2021 19:48
conditions/factory.go Outdated Show resolved Hide resolved
conditions/factory.go Outdated Show resolved Hide resolved
@joelanford
Copy link
Member Author

Closing this since there doesn't seem to be much interest in it. We can always re-visit/re-open if this comes up again.

@joelanford joelanford closed this Jun 8, 2021
@nunnatsa
Copy link
Contributor

Hi @joelanford. We want to re-try implementing the upgradable condition in HCO, now when bugzilla bug #1927340 is fixed. So we'll need a fix for #50.

@priyanka19-98
Copy link

We want to implement upgradeable condition in OCS , and will need fix for #50

@nunnatsa
Copy link
Contributor

nunnatsa commented Sep 2, 2021

@joelanford - could you please reconsider this? It will really help to have a solution for #50, to get more confidence in our implementation, because this is not easy to verify the behavior of the operator regarding the operator condition in e2e tests.

@joelanford joelanford reopened this Sep 8, 2021
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 8, 2021
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 9, 2021
The conditions.NewCondition function reads cluster state to determine
the namespace the operator is running in so that it can manipulate the
correct OperatorConditions object in a cluster.

However this function's dependency on a specific file existing in a
specific location makes it difficult to test code that uses it.

The Factory interface is introduced to enable users to provide their own
implementations for building a Condition object to manage OperatorCondition
resources. Users can now build a factory and inject it into code that builds
new conditions. This enables code under test to use the Factory abstraction
and enables operator authors to inject custom functionality needed when
writing tests.

Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
@nunnatsa
Copy link
Contributor

nunnatsa commented Oct 3, 2021

/lgtm

@varshaprasad96 - could you please merge this?

@openshift-ci
Copy link

openshift-ci bot commented Oct 3, 2021

@nunnatsa: changing LGTM is restricted to collaborators

In response to this:

/lgtm

@varshaprasad96 - could you please merge this?

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@varshaprasad96
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 14, 2021
@varshaprasad96
Copy link
Member

The PR looks good, I have no objections in merging it. I'll wait for a day for additional reviews if any, if not merge it.

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
/approved

@varshaprasad96
Copy link
Member

/approve

@openshift-ci
Copy link

openshift-ci bot commented Oct 14, 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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 14, 2021
@openshift-merge-robot openshift-merge-robot merged commit 22f6002 into operator-framework:main Oct 14, 2021
@joelanford joelanford deleted the conditions-factory branch October 20, 2021 02:45
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. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't run operators locally, when using the conditions package
9 participants