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

Add exponential back-off to retryStrategy #1782

Merged
merged 6 commits into from
Dec 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,21 @@
}
}
},
"io.argoproj.workflow.v1alpha1.Backoff": {
"type": "object",
"properties": {
"duration": {
"type": "string"
},
"factor": {
"type": "integer",
"format": "int32"
},
"maxDuration": {
"type": "string"
}
}
},
"io.argoproj.workflow.v1alpha1.ContinueOn": {
"description": "ContinueOn defines if a workflow should continue even if a task or step fails/errors. It can be specified if the workflow should continue when the pod errors, fails or both.",
"type": "object",
Expand Down Expand Up @@ -796,6 +811,10 @@
"description": "RetryStrategy provides controls on how to retry a workflow step",
"type": "object",
"properties": {
"backoff": {
"description": "Backoff is a backoff strategy",
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.Backoff"
},
"limit": {
"description": "Limit is the maximum number of attempts when retrying a container",
"type": "integer",
Expand Down
20 changes: 20 additions & 0 deletions examples/retry-backoff.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This example demonstrates the use of retry back offs
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: retry-backoff-
spec:
entrypoint: retry-backoff
templates:
- name: retry-backoff
retryStrategy:
limit: 10
backoff:
duration: 1 # Default unit is seconds. Could also be a Duration, e.g.: "2m", "6h", "1d"
factor: 2
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the bikeshedding, but should this not be called "base" instead, given that it is, in fact, the base of the exponential function?
Also, good work :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

Duration is actually what K8s uses :) I think because technically factor is optional; if left at 0 then the backoff would simply apply the same duration wait

maxDuration: "1m" # Default unit is seconds. Could also be a Duration, e.g.: "2m", "6h", "1d"
container:
image: python:alpine3.6
command: ["python", -c]
# fail with a 66% probability
args: ["import random; import sys; exit_code = random.choice([0, 1, 1]); sys.exit(exit_code)"]
Loading