Skip to content

Allow custom timeout when fetching container tags#235

Merged
rbren merged 1 commit intoFairwindsOps:masterfrom
joshfrench:configurable-timeout
Jul 5, 2023
Merged

Allow custom timeout when fetching container tags#235
rbren merged 1 commit intoFairwindsOps:masterfrom
joshfrench:configurable-timeout

Conversation

@joshfrench
Copy link
Copy Markdown
Contributor

This PR fixes #234

Checklist

  • I have signed the CLA
  • I have updated/added any relevant documentation

Description

What's the goal of this PR?

Allows user to override the default timeout to overcome slow/large queries when fetching container tags.

What changes did you make?

Added a new flag (--timeout/-t); use the value in context.WithTimeout instead of hard-coding it.

What alternative solution should we consider, if any?

Initially I'd proposed setting a limit on the number of flags fetched, but that depends on getting the tags in reverse order. According to the OCI Distribution Spec, "tags MUST be in lexical order (i.e. case-insensitive alphanumeric order)" so that's a non-starter 😅

For my use case, setting the timeout to 20 seconds is enough to grab all ~9800 tags from calico/node so one possibility would be to simply bump the default timeout in addition to (or instead of) this PR.

Alternatively, bumping the number of tags fetched in each batch or letting the user specify the batch size might also address the issue. A timeout feels more intuitive to me, though.

@joshfrench joshfrench requested review from bbensky and rbren as code owners June 29, 2023 16:09
klog.Exitf("Failed to bind show-errored-containers flag: %v", err)
}

findCmd.Flags().Uint16P("timeout", "t", 10, "When finding container images, the time in seconds before canceling the operation.")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

uint8 would cap at less than 5 minutes, which feels within the realm of possibility for a poorly-behaved repo. On the other hand, I can't imagine anyone needing more than 9 hours :)

--helm Show old helm releases. You can combine this flag with `--containers` to have both output in a single run.
-h, --help help for find
--show-non-semver When finding container images, show all containers even if they don't follow semver.
--show-errored-containers When finding container images, show errors encountered when scanning.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just adding --show-errored-containers to the overview while I'm at it.

Copy link
Copy Markdown
Member

@sudermanjr sudermanjr left a comment

Choose a reason for hiding this comment

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

This looks great to me. Thanks! I'll had it off to one of our codeowners to review as well.

@rbren
Copy link
Copy Markdown
Contributor

rbren commented Jul 5, 2023

Thank you!

@rbren rbren merged commit ace9df2 into FairwindsOps:master Jul 5, 2023
@joshfrench joshfrench mentioned this pull request Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nova times out when fetching ridiculous number of tags

3 participants