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

Create and set timeouts globally via a flag #43

Merged
merged 1 commit into from Apr 14, 2021

Conversation

joelanford
Copy link
Member

Signed-off-by: Joe Lanford joe.lanford@gmail.com

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

@exdx exdx left a comment

Choose a reason for hiding this comment

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

/lgtm

cfg.BindFlags(flags)
flags.DurationVar(&timeout, "timeout", 1*time.Minute, "The amount of time to wait before giving up on an operation.")
Copy link
Member

Choose a reason for hiding this comment

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

I like how by default this is equal to the same amount of time we now retry installplans. So there's some consistency in OLM behavior across projects. cc @benluddy

@@ -47,3 +68,10 @@ operators from the installed catalogs.`,

return cmd
}

func setContext(cmd *cobra.Command, ctx context.Context) { //nolint:golint
Copy link
Member

Choose a reason for hiding this comment

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

Looks funny, but this is the only way to set the unexported field I guess.

One thing worth noting is mentioned in spf13/cobra#1118 (comment) where this root command context would be propagated down to all children. This is what we want via this PR obviously, and if the user wanted to change it on a per-invocation basis they can set the --timeout flag on the CLI to whatever. This change would also encourage to build smaller command surfaces that can be used independently of others.

so a kubectl operator <command> --timeout 5m | kubectl operator <command> --timeout 10m could be appropriate in certain cases

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 14, 2021
@joelanford joelanford merged commit 9e5901c into operator-framework:main Apr 14, 2021
@joelanford joelanford deleted the global-timeout branch April 14, 2021 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants