【发布时间】:2022-01-12 14:23:28
【问题描述】:
我们的 Argo 工作流步骤中的一个可能会达到速率限制,我希望能够告诉 argo 它应该等待多长时间才能等待下一次重试。
有办法吗?
我在文档中看到了Retries,但它只讨论了重试计数和退避策略,而且看起来不能参数化。
【问题讨论】:
标签: rate-limiting retry-logic argo-workflows
我们的 Argo 工作流步骤中的一个可能会达到速率限制,我希望能够告诉 argo 它应该等待多长时间才能等待下一次重试。
有办法吗?
我在文档中看到了Retries,但它只讨论了重试计数和退避策略,而且看起来不能参数化。
【问题讨论】:
标签: rate-limiting retry-logic argo-workflows
据我所知,没有内置方法可以在下次重试之前添加暂停。
但是,您可以使用 Argo 的 exit handler 功能构建自己的。
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: exit-handler-with-pause-
spec:
arguments:
parameters
- name: pause-before-retry-seconds
value: "60"
entrypoint: intentional-fail
onExit: exit-handler
- name: intentional-fail
container:
image: alpine:latest
command: [sh, -c]
args: ["echo intentional failure; exit 1"]
- name: exit-handler
steps:
- - name: pause
template: pause
when: "{{workflow.status}} != Succeeded"
- name: pause
container:
image: alpine:latest
env:
- name: SECONDS
value: "{{workflow.parameters.pause-before-retry-seconds}}"
command: [sh, -c]
args:
- >-
echo "Pausing before retry..."
sleep "$SECONDS"
如果需要在工作流中计算重试暂停,请查看exit handler with params 示例。
【讨论】:
resource 模板组合在一起创建 CronWorkflow。
template: whatever 替换为 templateRef 块即可。