-
Notifications
You must be signed in to change notification settings - Fork 40
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
Conversation
@@ -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.") |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
Thank you! |
This PR fixes #234
Checklist
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 incontext.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.