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

cmd/operator-sdk/alpha: 'up/down olm' commands to run an operator #1912

Closed
wants to merge 41 commits into from

Conversation

estroz
Copy link
Member

@estroz estroz commented Sep 12, 2019

Description of the change:

  • cmd/operator-sdk/alpha: 'up/down olm' commands to run an operator on a cluster that has OLM installed
  • internal/olm/operator: logic to load an operator bundle into a registry Deployment from a ConfigMap and serve that bundle from an operator-registry server to OLM
  • internal/util/operator-registry: use registry bundle utilities to parse a manifests dir; some file renaming and added validation

Motivation for the change: OLM integration POC.

Test using:

$ operator-sdk alpha olm install
$ operator-sdk alpha up olm ${bundle_path} --operator-version ${semantic_version}
$ operator-sdk alpha down olm ${bundle_path} --operator-version ${semantic_version}

or integration tests:

$ make test-integration

Notes:

/cc @dmesser @ecordell

on a cluster that has OLM installed

internal/olm/operator: logic to load an operator bundle into a
registry Deployment from a ConfigMap and serve that bundle from
an operator-registry server to OLM
@estroz estroz added kind/feature Categorizes issue or PR as related to a new feature. olm-integration Issue relates to the OLM integration labels Sep 12, 2019
@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 12, 2019
Copy link
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.

Just a quick review with some questions and nits. Definitely want to give this a test run.

cmd/operator-sdk/alpha/cmd.go Outdated Show resolved Hide resolved
cmd.AddCommand(
olm.NewCmd(),
up.NewCmd(),
down.NewCmd(),
Copy link
Member

Choose a reason for hiding this comment

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

Do we need a down subcommand or can we make up olm/olm up work like up local, where we could create the resources, wait for the operator to run, tail the logs, and wait for the user to terminate the process. Then we could catch the signal, and tear everything down cleanly.

One problem with that approach (and there are probably others, e.g. scorecard use cases?) would be the user using SIGKILL, which cannot be caught and handled.

Thoughts?

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 imagine using operator-sdk alpha olm up to deploy an operator for both production and test purposes, so IMO having a process that doesn't return gives a test-only feel. down is for convenience, and likely won't/shouldn't be used in production.

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 think this needs more discussion regardless, since there are a few use cases to consider.

internal/olm/operator/internal/configmap.go Outdated Show resolved Hide resolved
internal/olm/operator/internal/deployment.go Outdated Show resolved Hide resolved
internal/olm/operator/internal/deployment.go Outdated Show resolved Hide resolved
internal/olm/operator/internal/deployment.go Show resolved Hide resolved
if m.force {
log.Printf("Forcefully recreating registry")
} else {
log.Printf("Registry data stale. Recreating registry")
Copy link
Member

Choose a reason for hiding this comment

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

Right now, it seems like the only difference between --force=true and --force=false is that in the former case, we'll delete and re-create the registry even when the registry data is correct.

Is there a use case for that? Maybe to get a newer registry image version?

Also, without --force, we still delete and re-create when the data is stale. Is there a use case that dictates that we should bail out with stale data and require the --force flag?

Copy link
Member Author

Choose a reason for hiding this comment

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

In this particular case --force=true isn't really useful, because as you say its not doing anything that a cache miss wouldn't.

I can't think of any case where we wouldn't want to rebuild the registry if its data is stale.

One slightly related thing I just thought of is that we don't necessarily have to re-create a Subscription and CatalogSource when rebuilding the registry, since they'll be pointing to the same registry server address. WDYT?

internal/olm/operator/olm.go Outdated Show resolved Hide resolved
// not the other is an error.
hasSub, hasCatSrc := m.hasSubscription(), m.hasCatalogSource()
if hasSub || hasCatSrc && !(hasSub && hasCatSrc) {
return nil, errors.New("both a CatalogSource and Subscription must be supplied if one is supplied")
Copy link
Member Author

Choose a reason for hiding this comment

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

We can likely relax this requirement in the future, as we can accept an external CatalogSource and write a Subscription internally referencing that CatalogSource.

@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 21, 2019
@estroz
Copy link
Member Author

estroz commented Nov 26, 2019

@camilamacedo86 alpha olm install/uninstall is already in master. Only alpha olm up/down are being added in this PR.

// with UnsupportedOperatorGroup.
//
// https://github.com/operator-framework/operator-lifecycle-manager/blob/master/doc/design/operatorgroups.md
func (m *operatorManager) operatorGroupUp(ctx context.Context) error {
Copy link
Member Author

Choose a reason for hiding this comment

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

@njhale @kevinrizza does this OperatorGroup logic make sense? I'm doing a thorough writeup of this logic and push that soon, which will further clarify my thinking.

Copy link
Member Author

Choose a reason for hiding this comment

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

Proposed logic: #2324

@estroz
Copy link
Member Author

estroz commented Dec 12, 2019

/hold

waiting on #2313 and #2324

@openshift-ci-robot openshift-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Dec 12, 2019
@openshift-ci-robot
Copy link

@estroz: PR needs rebase.

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.

@estroz
Copy link
Member Author

estroz commented Jan 15, 2020

Closing in favor of #2402

@estroz estroz closed this Jan 15, 2020
@estroz estroz deleted the olm-poc branch April 1, 2020 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/feature Categorizes issue or PR as related to a new feature. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. olm-integration Issue relates to the OLM integration size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants