-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Expand file tree
/
Copy pathretries.go
More file actions
43 lines (39 loc) · 2.11 KB
/
Copy pathretries.go
File metadata and controls
43 lines (39 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package keys
import v "github.com/argoproj/argo-workflows/v4/util/variables"
// retryableKinds are the template kinds that practice has shown actually
// honour retryStrategy and substitute {{retries}} / {{lastRetry.*}} into
// their bodies on each attempt. The validator (validate.go) injects
// retries / lastRetry.* into the per-template scope for any
// tmpl.RetryStrategy != nil regardless of kind, and the operator
// substitutes them into processedTmpl.
// Empirically verified end-to-end (initial + 2 retries, per-attempt
// substitution observed) for Container, ContainerSet, Script, Resource,
// Steps, DAG, HTTP, Data, and Plugin templates.
//
// Suspend is intentionally excluded: lint accepts retryStrategy on a
// suspend template, but suspend has no realistic failure path (the
// duration just elapses; explicit termination bypasses retries), so
// retry variables never actually bind in practice.
var retryableKinds = []v.TemplateKind{
v.TmplContainer, v.TmplContainerSet, v.TmplScript, v.TmplResource,
v.TmplSteps, v.TmplDAG,
v.TmplHTTP, v.TmplData, v.TmplPlugin,
}
// retries.* — inside retry-strategy templates.
// Bound only when retryStrategy is set; PhDuringExecute is implied and
// not listed separately, for the same reasons as item / item.<key>.
func retry(template, description string) *v.Key {
return v.Define(v.Spec{
Template: template, Kind: v.KindRetry, ValueType: "string", AppliesTo: retryableKinds,
Phases: []v.LifecyclePhase{v.PhInsideRetry},
Description: description,
})
}
var (
Retries = retry("retries", "0-based retry attempt index")
RetriesLastExitCode = retry("lastRetry.exitCode", "Exit code of the previous attempt (or 0 on first attempt)")
RetriesLastStatus = retry("lastRetry.status", "Phase of the previous attempt (or empty on first)")
RetriesLastDuration = retry("lastRetry.duration", "Duration of the previous attempt in seconds")
RetriesLastMessage = retry("lastRetry.message", "Message of the previous attempt")
RetriesExitCodes = retry("lastRetry.exitCodes", "Comma-separated exit codes of all previous attempts, oldest first (empty on the first attempt)")
)