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 --olm-namespace flag to OLM related subcommands #2613

Merged
merged 1 commit into from
Mar 23, 2020

Conversation

jeyaramashok
Copy link
Contributor

@jeyaramashok jeyaramashok commented Mar 2, 2020

Description of the change:

  • Add --olm-namespace flag to to operator-sdk run --olm command
  • Add --olm-namespace flag to operator-sdk olm status command
  • Add --olm-namespace flag to operator-sdk cleanup command

Motivation for the change:

This fixes the bug where running these commands against a openshift 4.x cluster would fail because in those clusters the OLM is installed in namesapce: openshift-operator-lifecycle-manager and the code always defaulted to default namespace: olm. Its now fixed by adding a new flag --olm-namespace that allows to override the default namespace(olm).

Closes: #2595

Example usage

# get OLM installation status
$ operator-sdk olm status --olm-namespace openshift-operator-lifecycle-manager

# run locally with OLM
$ operator-sdk run --olm \
--operator-version 0.1.0 \
--manifests sample-operator/deploy/olm-catalog/sample-operator \
--olm-namespace openshift-operator-lifecycle-manager

# cleanup
$ operator-sdk cleanup --olm \
--operator-version 0.1.0 \
--manifests sample-operator/deploy/olm-catalog/sample-operator \
--olm-namespace openshift-operator-lifecycle-manager

@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 2, 2020
@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 2, 2020
CHANGELOG.md Outdated Show resolved Hide resolved
@jeyaramashok
Copy link
Contributor Author

jeyaramashok commented Mar 2, 2020

hey guys, I am going to do some little rework after thinking through questions @camilamacedo86 asked. I think I made changes more than needed.

pls hold off review until then. I'l post one done.

CHANGELOG.md Outdated Show resolved Hide resolved
internal/olm/client.go Outdated Show resolved Hide resolved
internal/olm/client.go Outdated Show resolved Hide resolved
internal/olm/manager.go Outdated Show resolved Hide resolved
@@ -97,6 +100,8 @@ func (c *OLMCmd) AddToFlagSet(fs *pflag.FlagSet) {
"These supplement or override defaults generated by run/cleanup")
fs.DurationVar(&c.Timeout, "timeout", defaultTimeout,
prefix+"Time to wait for the command to complete before failing")
fs.StringVar(&c.OLMNamespace, "olm-namespace", olm.DefaultNamespace,
prefix+"OLM Namespace")
}

func (c *OLMCmd) validate() error {
Copy link
Member

Choose a reason for hiding this comment

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

Validate whether OLMCmd.OLMNamespace is set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OLMNamespace is currently optional, and it defaults to olm.DefaultNamespace(olm) , not sure what validation should be done?, can you pls provide an example if i'm missing anything

Copy link
Member

@estroz estroz Mar 4, 2020

Choose a reason for hiding this comment

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

It defaults to olm.DefaultNamespace in its flags, but what if OLMCmd is populated directly in code? OLMCmd.OLMNamespace isn't defaulted anywhere AFAIK, and is used directly by operatorManager methods.

Instead of validating, just default to olm.DefaultNamespace in newManager().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yes. added it now.

internal/olm/operator/operator.go Outdated Show resolved Hide resolved
internal/olm/operator/operator.go Show resolved Hide resolved
internal/olm/operator/manager.go Show resolved Hide resolved
@jeyaramashok
Copy link
Contributor Author

@camilamacedo86 @estroz addressed the review comments, pls review it.

@jeyaramashok jeyaramashok changed the title [wip] Add --olm-namespace flag to OLM related subcommands Add --olm-namespace flag to OLM related subcommands Mar 3, 2020
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 3, 2020
@jeyaramashok
Copy link
Contributor Author

pls let me know if I need to rebase the commits

Copy link
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

Hi @jeyaramashok,

Really thank you for the contribution. Added a few comments regards nits required. Could you please rebase and check them? Otherwise, it shows lgtm for me.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 11, 2020
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 11, 2020
@jeyaramashok
Copy link
Contributor Author

jeyaramashok commented Mar 11, 2020

rebased the commits

CHANGELOG.md Outdated Show resolved Hide resolved
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 13, 2020
@jeyaramashok
Copy link
Contributor Author

@camilamacedo86 I have address your comments in 6cfe531, let me know if the changes look okay or need any further changes. I'l rebase after that ( since its easy to look at changes with commits)

@jeyaramashok jeyaramashok force-pushed the fix_2595 branch 2 times, most recently from 1c0bc41 to 79fffe2 Compare March 15, 2020 00:11
Copy link
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

Btw, you have been doing terrific work here 🥇

Copy link
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

@hasbro17 @estroz wdyt?
/lgtm for me.

@camilamacedo86 camilamacedo86 added the lgtm Indicates that a PR is ready to be merged. label Mar 15, 2020
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 21, 2020
Copy link
Member

@estroz estroz 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-robot openshift-ci-robot removed lgtm Indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Mar 22, 2020
@jeyaramashok
Copy link
Contributor Author

rebased the PR with master, and made a minor change in the flag section, to move --olm-namespace flag next to --operator-namespace (which is a newly added flag in master), so the help text looks better

      --olm                         The operator to be cleaned up is managed by OLM in a cluster. Cannot be set with another cleanup-type flag (default true)
      --olm-namespace string        [olm only] The namespace where OLM is installed (default "olm")
      --operator-namespace string   [olm only] The namespace where operator resources are created in --olm mode. It must already exist in the cluster or be defined in a manifest passed to IncludePaths.

@estroz
Copy link
Member

estroz commented Mar 22, 2020

@jeyaramashok we just added website docs to the SDK repo, and some docs need to be duplicated. Run

$ cp ./doc/cli/* ./website/content/en/docs/cli/

to duplicate the cli docs changes.

@jeyaramashok
Copy link
Contributor Author

jeyaramashok commented Mar 22, 2020

copied the docs to other directory. I found operator-sdk_new.md was not in sync betweencli & website directories and the examples in it was not indented properly, so I updated it as well in this commit f0ccd91 . If this looks okay, I'll rebase the PR

Copy link
Member

@estroz estroz 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-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 22, 2020
@estroz
Copy link
Member

estroz commented Mar 22, 2020

Looks like the go string literals in command files have bad indentation. Feel free to revert the indentation changes, or change indentation in the go filed themselves. I will make a follow up PR in the former case.

@openshift-ci-robot
Copy link

New changes are detected. LGTM label has been removed.

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Mar 22, 2020
@jeyaramashok
Copy link
Contributor Author

@estroz fixed the indentation in source file

@@ -53,48 +53,48 @@ generates a default directory layout based on the input <project-name>.
<project-name> is the project name of the new operator. (e.g app-operator)
`,
Example: `# Create a new project directory
Copy link
Member

Choose a reason for hiding this comment

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

Last nit (should have mentioned this before): would be nice to have two spaces indenting each examples line:

Suggested change
Example: `# Create a new project directory
Example: ` # Create a new project directory

and so on.

Then the printout of examples aligns with Usage:

$ operator-sdk new --help
The operator-sdk new command creates a new operator application and
generates a default directory layout based on the input <project-name>.

<project-name> is the project name of the new operator. (e.g app-operator)

Usage:
  operator-sdk new <project-name> [flags]

Examples:
  # Create a new project directory
  $ mkdir $HOME/projects/example.com/
  $ cd $HOME/projects/example.com/
...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok done. now I understand why it was indented before :)

- Add '--olm-namespace' flag to to 'operator-sdk run --olm' command
- Add '--olm-namespace' flag to 'operator-sdk olm status' command
- Add '--olm-namespace' flag to 'operator-sdk cleanup' command

This fixes the bug where running these commands against a openshift 4.x
cluster would fail because in those clusters the OLM is installed in
'namesapce: openshift-operator-lifecycle-manager' and the code always
defaulted to default 'namespace: olm'. Its now fixed by adding a new
flag '--olm-namespace' that allows to override the default namespace
(olm).

Fixes: operator-framework#2595
@estroz estroz merged commit 258189c into operator-framework:master Mar 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OLM related sub commands don't work with openshift 4.x cluster
4 participants