Skip to content

Commit 35e2b61

Browse files
committed
fix: cron, retry on fail submission
Signed-off-by: Tianchu Zhao <[email protected]>
1 parent b966acc commit 35e2b61

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

workflow/cron/operator.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,21 @@ func (woc *cronWfOperationCtx) run(ctx context.Context, scheduledRuntime time.Ti
100100

101101
wf := common.ConvertCronWorkflowToWorkflowWithProperties(woc.cronWf, getChildWorkflowName(woc.cronWf.Name, scheduledRuntime), scheduledRuntime)
102102

103-
runWf, err := util.SubmitWorkflow(ctx, woc.wfClient, woc.wfClientset, woc.cronWf.Namespace, wf, &v1alpha1.SubmitOpts{})
103+
var runWf *v1alpha1.Workflow
104+
// DefaultRetry is k8s default retry, also used by k8s client, retry 5 times
105+
err = waitutil.Backoff(retry.DefaultRetry, func() (bool, error) {
106+
var err error
107+
runWf, err = util.SubmitWorkflow(ctx, woc.wfClient, woc.wfClientset, woc.cronWf.Namespace, wf, &v1alpha1.SubmitOpts{})
108+
if err != nil {
109+
if errors.IsAlreadyExists(err) {
110+
return true, err
111+
}
112+
woc.log.Warnf("Failed to submit Workflow, intermittent: %s", err)
113+
// return false will trigger retry
114+
return false, err
115+
}
116+
return true, nil
117+
})
104118
if err != nil {
105119
// If the workflow already exists (i.e. this is a duplicate submission), do not report an error
106120
if errors.IsAlreadyExists(err) {

0 commit comments

Comments
 (0)