Skip to content

Catalog switcher #2281

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

Merged

Conversation

jchunkins
Copy link
Contributor

Description of the change:

Implementation of catalog switching enhancement proposal

Quick check for e2e test:

make e2e-local TEST='adding catalog template adjusts image used'

Motivation for the change:

See summary and motivation of enhancement proposal.

Reviewer Checklist

  • Implementation matches the proposed design, or proposal is updated to match implementation
  • Sufficient unit test coverage
  • Sufficient end-to-end test coverage
  • Docs updated or added to /doc
  • Commit messages sensible and descriptive

@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 Jul 22, 2021
@openshift-ci openshift-ci bot requested review from ecordell and timflannagan July 22, 2021 19:13
@openshift-ci openshift-ci bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 22, 2021
@openshift-ci
Copy link

openshift-ci bot commented Jul 22, 2021

Hi @jchunkins. Thanks for your PR.

I'm waiting for a operator-framework member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 22, 2021
@kevinrizza
Copy link
Member

/ok-to-test

@openshift-ci openshift-ci bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 22, 2021
@jchunkins jchunkins changed the title WIP Catalog switcher Catalog switcher Jul 22, 2021
@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 Jul 22, 2021
@kevinrizza
Copy link
Member

/approve

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 22, 2021
@kevinrizza
Copy link
Member

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 22, 2021
// of a value in the slice means that the template was either not found in the cache or its value has not been
// fetched yet). Providing an empty catalogImageTemplate results in empty processedCatalogImageTemplate and
// zero length unresolvedTemplates
func ReplaceTemplates(catalogImageTemplate string) (processedCatalogImageTemplate string, unresolvedTemplates []string) {
Copy link
Member

Choose a reason for hiding this comment

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

without the dynamic gvk templating, this could probably be simplified to a call to the stdlib template package

Copy link
Member

Choose a reason for hiding this comment

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

also: since any unresolved components should mean the image reference is invalid, I'm not sure I get the value in returning a partially-resolved reference and a list of the unresolved ones: why not just return an error with the missing values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The unresolvedTemplates are used to inform the user in a message about exactly what template that was not resolvable. It is used in messages exposed in both the log and the status conditions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also the processedCatalogImageTemplate is used to inform the user of what the template looks like in the status conditions. It helps the user see what's wrong by looking at the message AND what the templating code computed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like to address the security shortcomings of the GVK feature in the future, so I'd like to keep things as close to "working" as possible.

@jchunkins
Copy link
Contributor Author

It looks like unit / unit (pull_request) GitHub action failed, but when I run the error test case TestSyncOperatorGroups on my machine it does not have an error. Not sure how to restart the GitHub action to prove that its a flake of some kind.

@exdx
Copy link
Member

exdx commented Jul 26, 2021

It looks like unit / unit (pull_request) GitHub action failed, but when I run the error test case TestSyncOperatorGroups on my machine it does not have an error. Not sure how to restart the GitHub action to prove that its a flake of some kind.

It's a well known flake, I restarted it

- implements catalog switching proposal
See https://github.com/operator-framework/enhancements/blob/master/enhancements/automatic-catalog-switching-annotations.md
- picks up v0.10.3
- change sed command in copy_crds.sh to be posix compliant

The command + in sed is non-portable. The posix compliant version of
this command is {1,}

This change allows this script to run on a mac too (which uses BSD sed)

See https://riptutorial.com/sed/topic/9436/bsd-macos-sed-vs--gnu-sed-vs--the-posix-sed-specification

Note: GVK was implemented but disabled due to security concerns.
Future versions will address these concerns

Signed-off-by: John Hunkins <[email protected]>
- reorganize imports
- change logging common case to debug

Signed-off-by: John Hunkins <[email protected]>
- this is the commit that should be reviewed later
when it comes time to re-enable the GVK code

Signed-off-by: John Hunkins <[email protected]>
- fix names that don't match Golang convention
- fix misspelled package name
- return nil for sync function casting

Signed-off-by: John Hunkins <[email protected]>
- clean up every instance of the GVK templating feature
- add last minute change for RWMutex instead of Mutex

- this is the second commit that should be reviewed later
when it comes time to re-enable the GVK code

Signed-off-by: John Hunkins <[email protected]>
Copy link
Member

@njhale njhale left a comment

Choose a reason for hiding this comment

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

looking really good. thank you for addressing all the feedback so far! I think we're in the home stretch.

- update logging for clarity
- clean up code blocks
- refactor catalogsource helper functions:
  - remove mutex
  - remove two step get/update* in preference to update* even though
    this may result in more "the object has been modified" errors
  - rename helper functions to clarify usage
  - clarify the update helper function docs

Signed-off-by: John Hunkins <[email protected]>
Copy link
Member

@njhale njhale left a comment

Choose a reason for hiding this comment

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

/hold cancel
/lgtm

@jchunkins thanks for sticking with this through all the feedback!

I'd be interested in any thoughts you have about your experience contributing; e.g. good, bad, suggestions. Maybe we can continue in slack.

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 30, 2021
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 30, 2021
@openshift-ci
Copy link

openshift-ci bot commented Jul 30, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jchunkins, kevinrizza, njhale

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. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Need a consistent way to manage switching out a custom operator catalog as clusters are being upgraded to newer versions
7 participants