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

OLM operator support for downstream plug-ins #2843

Merged

Conversation

perdasilva
Copy link
Collaborator

@perdasilva perdasilva commented Aug 17, 2022

Signed-off-by: perdasilva [email protected]

Description of the change:
This PR introduces the concept of a plug-in for the OLM controller. Plugins can be injected downstream through the unexported operatorPlugIns package variable. Once the OLM controller is finished initializing, it will instantiate each of the plugins in turn.

Motivation for the change:
We need to add some downstream only code for handling csvs in lights of the label sync'er. This code will act on csv additions (non-copied csvs) and add a label to the namespace the csv belongs to, if it's not already there.

Architectural changes:
Adds an unexported package variable that carries the references to the plug-ins and initializes.
Adds some accessor methods to the operatorConfig to make some configuration information available to the plug-in
Breaks up the Operator interface into three interfaces to reduce the level of access to operator methods by the plug-in

Testing remarks:
No functional changes are brought in by this PR. No testing required.

Reviewer Checklist

  • Implementation matches the proposed design, or proposal is updated to match implementation
  • Sufficient unit test coverage
  • Sufficient end-to-end test coverage
  • Bug fixes are accompanied by regression test(s)
  • e2e tests and flake fixes are accompanied evidence of flake testing, e.g. executing the test 100(0) times
  • tech debt/todo is accompanied by issue link(s) in comments in the surrounding code
  • Tests are comprehensible, e.g. Ginkgo DSL is being used appropriately
  • Docs updated or added to /doc
  • Commit messages sensible and descriptive
  • Tests marked as [FLAKE] are truly flaky and have an issue
  • Code is properly formatted

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 17, 2022
@openshift-ci openshift-ci bot requested review from anik120 and njhale August 17, 2022 11:19
@perdasilva perdasilva changed the title [WIP] Refactor csv event listener to support multiple listeners and admit r… [WIP] Refactor csv event listener to support Aug 17, 2022
@openshift-ci
Copy link

openshift-ci bot commented Aug 17, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: perdasilva

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 Aug 17, 2022
@perdasilva perdasilva force-pushed the csv_event_handling branch 8 times, most recently from ea79ffa to 0b015f8 Compare August 23, 2022 09:37
@perdasilva perdasilva changed the title [WIP] Refactor csv event listener to support OLM operator support for downstream plug-ins Aug 23, 2022
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 23, 2022
@perdasilva perdasilva force-pushed the csv_event_handling branch 5 times, most recently from 9c2aaa4 to 881b8be Compare August 25, 2022 15:49
@@ -37,6 +37,26 @@ type operatorConfig struct {
configClient configv1client.Interface
}

func (o *operatorConfig) OperatorClient() operatorclient.ClientInterface {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These chances go in conjunction with the OperatorConfig client interface on the plug-in package. This way the plug-in can have access to some of the configuration information

@@ -61,6 +61,10 @@ var (
ErrAPIServiceOwnerConflict = errors.New("unable to adopt APIService")
)

// this unexported operator plugin slice provides an entrypoint for
// downstream to inject its own plugins to augment the controller behavior
var operatorPlugInFactoryFuncs []plugins.OperatorPlugInFactoryFunc
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Using factory functions instead of the instantiated plug-in objects themselves. This guarantees that each instance of the operator gets their own instance of the plug-ins

@grokspawn
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 29, 2022
@openshift-merge-robot openshift-merge-robot merged commit 35c5af2 into operator-framework:master Aug 29, 2022
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.

4 participants