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

Allow custom timeout when fetching container tags #235

Merged
merged 1 commit into from
Jul 5, 2023

Conversation

joshfrench
Copy link
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 rbren and bbensky as code owners June 29, 2023 16:09
@@ -131,6 +131,12 @@ func init() {
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
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 :)

@@ -15,7 +15,9 @@ Flags:
--containers Show old container image versions. There will be no helm output unless the --helm flag is set as well
--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
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
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
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