Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

feat: optional command timeout field in config file that defaults to syncTimeout #3228

Merged
merged 1 commit into from
Oct 27, 2020
Merged

feat: optional command timeout field in config file that defaults to syncTimeout #3228

merged 1 commit into from
Oct 27, 2020

Conversation

marshallford
Copy link
Contributor

@marshallford marshallford commented Jul 31, 2020

Adds the ability to set an optional timeout duration for all commands that defaults to the sync timeout instead of time.Minute. Attempts to resolve: #3049. Keep in mind that in order to fix the issue described, the sync timeout must be greater than or equal to the sum of the generator command timeouts. I am open to ideas or to scraping this completely. Thanks Flux team!

Example:

version: 1
patchUpdated:
  generators:
  - command: kustomize build .
    timeout: 3m # if field is not provided, sync timeout is used
  patchFile: flux-patch.yaml

Couple of other notes:

  1. I looked into parsing timeout from the config yaml as the type time.Duration instead of a string but the use of the ghodss/yaml package made that a bit confusing (for a new golang user anyway). It would have been nice to return an error in ParseConfigFile if an invalid duration was given instead of using the syncTimeout as a default without notice.

Solved by C&P this snippet: https://stackoverflow.com/a/48051946

  1. I'm not super happy with adding the field defaultTimeout to the configAware struct. Open to suggestions on how to improve passing through the sync timeout.

TODO:

  • Investigate better way of passing around/through sync timeout flag
  • Update docs once this method of setting a command timeout per generator is approved

@marshallford marshallford changed the title feat: generator command timeout field in config file and defaults other command timeouts to syncTimeout feat: optional command timeout field in config file that defaults to syncTimeout Aug 3, 2020
@marshallford
Copy link
Contributor Author

@stefanprodan could I get a review on this? Would you be open to a schema change like this?

@marshallford
Copy link
Contributor Author

@stefanprodan ping

@marshallford
Copy link
Contributor Author

ping @hiddeco

@rdubya16
Copy link

rdubya16 commented Oct 1, 2020

@stefanprodan Any movement on this? This is blocking us as well.

@mike-stewart
Copy link

@squaremo We're running into this bug as well. We are running a build of this PR in one of our clusters now, and it seems to be resolving the issue. Any chance this PR could be merged?

Copy link
Member

@squaremo squaremo left a comment

Choose a reason for hiding this comment

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

Thanks for putting time into this! I appreciate the need, and I'm happy with the idea. Passing the default timeout is a bit awkward, as you mention; I'm fine with it though, at least it's obvious what's happening.
There's some bits in the implementation that need another look, which I've flagged up.

pkg/daemon/daemon.go Outdated Show resolved Hide resolved
pkg/manifests/configfile.go Outdated Show resolved Hide resolved
pkg/manifests/configfile.go Show resolved Hide resolved
pkg/manifests/configfile.go Outdated Show resolved Hide resolved
@squaremo
Copy link
Member

I've rebased this, and added a commit for using metav1.Duration. Once it passes CI I'll squash those early few commits and merge.

@marshallford
Copy link
Contributor Author

I've rebased this, and added a commit for using metav1.Duration. Once it passes CI I'll squash those early few commits and merge.

Awesome Thanks!

@squaremo
Copy link
Member

@marshallford Can you do me a quick favour? We now require a DCO (as of today!). It's pretty easy to apply it -- instructions are in that link, and you will need to git reset your local branch head first, to pick up my rebase.

This gives more flexibility to .flux.yaml authors, by letting them
give a timeout (as a duration e.g., `"30s"`) for each command
individually.

Signed-off-by: Marshall Ford <inbox@marshallford.me>
@squaremo squaremo merged commit 201200c into fluxcd:master Oct 27, 2020
@squaremo
Copy link
Member

Brill, thank you @marshallford!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--sync-timeout is capped at 60s
4 participants