-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat: allow lastRetry variables in expressions #12722
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2128,6 +2128,24 @@ func (woc *wfOperationCtx) executeTemplate(ctx context.Context, nodeName string, | |
| // Inject the retryAttempt number | ||
| localParams[common.LocalVarRetries] = strconv.Itoa(retryNum) | ||
|
|
||
| // Inject lastRetry variables | ||
| // the first node will not have "lastRetry" variables so they must have default values | ||
| // for the expression to resolve | ||
|
Comment on lines
+2131
to
+2133
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| lastRetryExitCode, lastRetryDuration := "0", "0" | ||
| var lastRetryStatus, lastRetryMessage string | ||
| if lastChildNode != nil { | ||
| if lastChildNode.Outputs != nil && lastChildNode.Outputs.ExitCode != nil { | ||
| lastRetryExitCode = *lastChildNode.Outputs.ExitCode | ||
| } | ||
| lastRetryStatus = string(lastChildNode.Phase) | ||
| lastRetryDuration = fmt.Sprint(lastChildNode.GetDuration().Seconds()) | ||
| lastRetryMessage = lastChildNode.Message | ||
| } | ||
| localParams[common.LocalVarRetriesLastExitCode] = lastRetryExitCode | ||
| localParams[common.LocalVarRetriesLastDuration] = lastRetryDuration | ||
| localParams[common.LocalVarRetriesLastStatus] = lastRetryStatus | ||
| localParams[common.LocalVarRetriesLastMessage] = lastRetryMessage | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this function is already so long, can we separate this new logic into a function to build the local scope from
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignore this comment if this comment ends up making more sense
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we could use the output from |
||
| processedTmpl, err = common.SubstituteParams(processedTmpl, woc.globalParams, localParams) | ||
| if errorsutil.IsTransientErr(err) { | ||
| return node, err | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
Since we're already using
LocalVarRetriesin this scope, it does seem reasonable to me to use these other variables in the general template scope as well.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.
Actually, I haven't looked at it long enough, but I am kind of wondering if there's a way to do this and not have to be setting these same variables twice. Should
processNodeRetries()possibly take alocalScopeand then be able to modify it and return it to the caller? You have probably looked at the code longer than I have - what do you think?