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

refactor: action retry to use go-retry #2868

Closed
wants to merge 2 commits into from
Closed

Conversation

phillebaba
Copy link
Contributor

Description

This change replaces the custom retry logic with using go-retry. It simplifies legibility a lot by removing use of labels to break out of the outer loop.

Related Issue

Depends on #2856

Checklist before merging

@phillebaba phillebaba requested review from a team as code owners August 12, 2024 10:19
@phillebaba phillebaba marked this pull request as draft August 12, 2024 10:35
spinner.Updatef("Waiting for \"%s\" %s", cmdEscaped, timeoutStr)
}),
)
if actionCtx.Err() != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will also happen on context cancel so need another way of checking for timeout. An option is to use with cause.

// Try running the command and continue the retry loop if it fails.
if out, err = actionRun(ctx, actionDefaults, cmd, actionDefaults.Shell, spinner); err != nil {
// If an output variable is defined, set it.
for _, v := range action.SetVariables {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should this be retried? It it seems like this was done because implementing it would have been difficult in the old code. It seems a lot smarter to only retry the action on errors and not the setting on variables as I assume the output variables will be the same every time the actions run.

@phillebaba
Copy link
Contributor Author

Before merging we should add tests to the Run function to validate the error output for the different failure modes.

@phillebaba phillebaba closed this Sep 3, 2024
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.

1 participant