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

Set REST timeout when timeout cli arg is provided #6440

Closed
wants to merge 1 commit into from

Conversation

sebsoto
Copy link
Contributor

@sebsoto sebsoto commented May 19, 2023

Description of the change:
The timeout arg sets the overall timeout for the full command to finish, such as run bundle, but it doesn't affect the timeout of individual API server requests. This remains the default timeout specified in the API server configuration. This means that even if a user wants run bundle to timeout after 5m, the command may return earlier due to an individual request's timeout being hit.

This commit fixes that behavior by setting the Timeout value in the client cfg to the value passed in by the user, this will prevent the individual request from timing out before the desired timeout.

Motivation for the change:
operator-sdk bundle run fails on operators that take longer than usual to install

@sebsoto sebsoto force-pushed the timeoutChange branch 4 times, most recently from ad2a925 to 5d02640 Compare May 19, 2023 14:16
@sebsoto sebsoto temporarily deployed to deploy May 19, 2023 15:06 — with GitHub Actions Inactive
@sebsoto sebsoto temporarily deployed to deploy May 19, 2023 15:06 — with GitHub Actions Inactive
@sebsoto sebsoto temporarily deployed to deploy May 19, 2023 15:06 — with GitHub Actions Inactive
@sebsoto sebsoto temporarily deployed to deploy May 19, 2023 15:06 — with GitHub Actions Inactive
@sebsoto sebsoto temporarily deployed to deploy May 19, 2023 15:06 — with GitHub Actions Inactive
@sebsoto sebsoto temporarily deployed to deploy May 19, 2023 15:06 — with GitHub Actions Inactive
@sebsoto sebsoto temporarily deployed to deploy May 19, 2023 15:06 — with GitHub Actions Inactive
Copy link
Contributor

@everettraven everettraven left a comment

Choose a reason for hiding this comment

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

@sebsoto Thanks for taking the time to write up this contribution! Overall I think the change suggested is reasonable, but I think the existing change doesn't actually address this. I left a comment that elaborates on this a bit more:

Copy link
Contributor

Choose a reason for hiding this comment

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

So I think this sounds like a reasonable change, however I think this is being done in the wrong file based on the context given in the PR description. This configuration is only for the operator-sdk olm install command and doesn't apply broadly to all commands.

I can see an argument for applying this more broadly but based on the PR description this change seems to be more focused on updating operator-sdk run bundle and I'd personally prefer to keep this PR scoped to only that command set for now. Having said that, the appropriate place to make this change would likely be in this function:

func (c *Configuration) Load() error {
if c.overrides == nil {
c.overrides = &clientcmd.ConfigOverrides{}
}
loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
loadingRules.ExplicitPath = c.KubeconfigPath
mergedConfig, err := loadingRules.Load()
if err != nil {
return err
}
cfg := clientcmd.NewDefaultClientConfig(*mergedConfig, c.overrides)
cc, err := cfg.ClientConfig()
if err != nil {
return err
}
ns, _, err := cfg.Namespace()
if err != nil {
return err
}
sch := scheme.Scheme
for _, f := range []func(*runtime.Scheme) error{
v1alpha1.AddToScheme,
v1.AddToScheme,
apiextv1.AddToScheme,
} {
if err := f(sch); err != nil {
return err
}
}
cl, err := client.New(cc, client.Options{
Scheme: sch,
})
if err != nil {
return err
}
c.Scheme = sch
c.Client = &operatorClient{cl}
if c.Namespace == "" {
c.Namespace = ns
}
c.RESTConfig = cc
return nil
}

IIRC this configuration type is the configuration that is used for both operator-sdk run bundle and operator-sdk run bundle-upgrade commands so modifying this Configuration.Load() function should help address the issue you outlined in the PR description.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review, sorry it took so long for me to get back to this. I took a crack at moving the change to the file you suggested.

Please let me know if I'm misusing the overrides struct, I wasn't sure if this would be the correct way to set the timeout.

@openshift-bot
Copy link

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 21, 2023
@sebsoto
Copy link
Contributor Author

sebsoto commented Sep 6, 2023

/remove-lifecycle stale

@openshift-ci openshift-ci bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 6, 2023
The timeout arg sets the overall timeout for the full command to finish,
such as `run bundle`, but it doesn't affect the timeout of individual
API server requests. This remains the default timeout specified
in the API server configuration. This means that even if a user wants
`run bundle` to timeout after 5m, the command may return earlier due to
an individual request's timeout being hit.

This commit fixes that behavior by setting the Timeout value in the
client cfg to the value passed in by the user, this will prevent the
individual request from timing out before the desired timeout.

Signed-off-by: Sebastian Soto <ssoto@redhat.com>
@sebsoto
Copy link
Contributor Author

sebsoto commented Sep 20, 2023

@everettraven Could you take another a look at this when you get a chance? Thanks!

@everettraven
Copy link
Contributor

Looks like the actions here are stuck. Going to close and re-open to kick them

@everettraven everettraven reopened this Oct 20, 2023
@everettraven everettraven temporarily deployed to deploy October 20, 2023 13:49 — with GitHub Actions Inactive
@everettraven everettraven temporarily deployed to deploy October 20, 2023 13:49 — with GitHub Actions Inactive
@everettraven everettraven temporarily deployed to deploy October 20, 2023 13:49 — with GitHub Actions Inactive
@everettraven everettraven temporarily deployed to deploy October 20, 2023 13:49 — with GitHub Actions Inactive
@everettraven everettraven temporarily deployed to deploy October 20, 2023 13:49 — with GitHub Actions Inactive
@openshift-bot
Copy link

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci openshift-ci bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 19, 2024
@openshift-bot
Copy link

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten
/remove-lifecycle stale

@openshift-ci openshift-ci bot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Feb 18, 2024
@openshift-bot
Copy link

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

@openshift-ci openshift-ci bot closed this Mar 20, 2024
Copy link

openshift-ci bot commented Mar 20, 2024

@openshift-bot: Closed this PR.

In response to this:

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.

/close

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants