@@ -260,41 +260,47 @@ type containerExecutorInputs struct {
260
260
// name: argo workflows DAG task name
261
261
// The other arguments are argo workflows task parameters, they can be either a
262
262
// string or a placeholder.
263
- func (c * workflowCompiler ) containerExecutorTask (name string , inputs containerExecutorInputs , refName string ) * wfapi.DAGTask {
263
+ func (c * workflowCompiler ) containerExecutorTask (name string , inputs containerExecutorInputs , task * pipelinespec. PipelineTaskSpec ) * wfapi.DAGTask {
264
264
when := ""
265
265
if inputs .condition != "" {
266
266
when = inputs .condition + " != false"
267
267
}
268
- task := & wfapi.DAGTask {
268
+ dagTask := & wfapi.DAGTask {
269
269
Name : name ,
270
- Template : c .addContainerExecutorTemplate (name , refName ),
270
+ Template : c .addContainerExecutorTemplate (task ),
271
271
When : when ,
272
272
Arguments : wfapi.Arguments {
273
273
Parameters : append ([]wfapi.Parameter {
274
274
{Name : paramPodSpecPatch , Value : wfapi .AnyStringPtr (inputs .podSpecPatch )},
275
- {Name : paramCachedDecision , Value : wfapi .AnyStringPtr (inputs .cachedDecision ), Default : wfapi .AnyStringPtr ("false" )}},
276
- c .getTaskRetryParametersWithValues (name )... ,
275
+ {Name : paramCachedDecision , Value : wfapi .AnyStringPtr (inputs .cachedDecision ), Default : wfapi .AnyStringPtr ("false" )},
276
+ },
277
+ c .getTaskRetryParametersWithValues (task )... ,
277
278
),
278
279
},
279
280
}
280
281
281
- addExitTask (task , inputs .exitTemplate , inputs .hookParentDagID )
282
+ addExitTask (dagTask , inputs .exitTemplate , inputs .hookParentDagID )
282
283
283
- return task
284
+ return dagTask
284
285
}
285
286
286
287
// addContainerExecutorTemplate adds a generic container executor template for
287
288
// any container component task.
288
289
// During runtime, it's expected that pod-spec-patch will specify command, args
289
290
// and resources etc, that are different for different tasks.
290
- func (c * workflowCompiler ) addContainerExecutorTemplate (name string , refName string ) string {
291
+ func (c * workflowCompiler ) addContainerExecutorTemplate (task * pipelinespec. PipelineTaskSpec ) string {
291
292
// container template is parent of container implementation template
292
293
nameContainerExecutor := "system-container-executor"
293
294
nameContainerImpl := "system-container-impl"
294
- taskRetrySpec := c .getTaskRetryPolicySpec (name )
295
+ taskRetrySpec := task .GetRetryPolicy ()
296
+ refName := task .GetComponentRef ().GetName ()
295
297
if taskRetrySpec != nil {
296
- nameContainerExecutor = "retry-" + nameContainerExecutor
297
- nameContainerImpl = "retry-" + nameContainerImpl
298
+ task := c .spec .Components [refName ]
299
+ // retry-system-container-executor/impl is used if retry is set at the component level (if task is not a DAG)
300
+ if task != nil && task .GetDag () == nil {
301
+ nameContainerExecutor = "retry-" + nameContainerExecutor
302
+ nameContainerImpl = "retry-" + nameContainerImpl
303
+ }
298
304
}
299
305
_ , ok := c .templates [nameContainerExecutor ]
300
306
if ok {
@@ -305,8 +311,9 @@ func (c *workflowCompiler) addContainerExecutorTemplate(name string, refName str
305
311
Inputs : wfapi.Inputs {
306
312
Parameters : append ([]wfapi.Parameter {
307
313
{Name : paramPodSpecPatch },
308
- {Name : paramCachedDecision , Default : wfapi .AnyStringPtr ("false" )}},
309
- c .addParameterDefault (c .getTaskRetryParameters (name ), "0" )... ,
314
+ {Name : paramCachedDecision , Default : wfapi .AnyStringPtr ("false" )},
315
+ },
316
+ c .addParameterDefault (c .getTaskRetryParameters (task ), "0" )... ,
310
317
),
311
318
},
312
319
DAG : & wfapi.DAGTemplate {
@@ -316,8 +323,9 @@ func (c *workflowCompiler) addContainerExecutorTemplate(name string, refName str
316
323
Arguments : wfapi.Arguments {
317
324
Parameters : append ([]wfapi.Parameter {{
318
325
Name : paramPodSpecPatch ,
319
- Value : wfapi .AnyStringPtr (inputParameter (paramPodSpecPatch ))}},
320
- c .addParameterInputPath (c .getTaskRetryParameters (name ))... ,
326
+ Value : wfapi .AnyStringPtr (inputParameter (paramPodSpecPatch ))},
327
+ },
328
+ c .addParameterInputPath (c .getTaskRetryParameters (task ))... ,
321
329
),
322
330
},
323
331
// When cached decision is true, the container
@@ -347,8 +355,9 @@ func (c *workflowCompiler) addContainerExecutorTemplate(name string, refName str
347
355
Name : nameContainerImpl ,
348
356
Inputs : wfapi.Inputs {
349
357
Parameters : append ([]wfapi.Parameter {
350
- {Name : paramPodSpecPatch }},
351
- c .getTaskRetryParameters (name )... ),
358
+ {Name : paramPodSpecPatch },
359
+ },
360
+ c .getTaskRetryParameters (task )... ),
352
361
},
353
362
// PodSpecPatch input param is where actual image, command and
354
363
// args come from. It is treated as a strategic merge patch on
@@ -530,34 +539,23 @@ func (c *workflowCompiler) addContainerExecutorTemplate(name string, refName str
530
539
return nameContainerExecutor
531
540
}
532
541
533
- func (c * workflowCompiler ) getTaskRetryPolicySpec (name string ) * pipelinespec.PipelineTaskSpec_RetryPolicy {
534
- if c .spec == nil || c .spec .Root == nil || c .spec .Root .GetDag () == nil {
535
- return nil
536
- }
537
- rootDag := c .spec .Root .GetDag ()
538
- taskSpec := rootDag .Tasks [name ]
539
- if taskSpec == nil {
540
- return nil
541
- }
542
- return taskSpec .RetryPolicy
543
- }
544
-
545
- func (c * workflowCompiler ) getTaskRetryParameters (name string ) []wfapi.Parameter {
546
- retryPolicy := c .getTaskRetryPolicySpec (name )
547
- if retryPolicy == nil {
542
+ func (c * workflowCompiler ) getTaskRetryParameters (task * pipelinespec.PipelineTaskSpec ) []wfapi.Parameter {
543
+ if task != nil && task .RetryPolicy != nil {
544
+ // Create slice of parameters with "Name" field set.
545
+ parameters := []wfapi.Parameter {
546
+ {Name : paramRetryMaxCount },
547
+ {Name : paramRetryBackOffDuration },
548
+ {Name : paramRetryBackOffFactor },
549
+ {Name : paramRetryBackOffMaxDuration },
550
+ }
551
+ return parameters
552
+ } else {
548
553
return nil
549
554
}
550
- // Create slice of parameters with "Name" field set.
551
- parameters := []wfapi.Parameter {
552
- {Name : paramRetryMaxCount },
553
- {Name : paramRetryBackOffDuration },
554
- {Name : paramRetryBackOffFactor },
555
- {Name : paramRetryBackOffMaxDuration }}
556
- return parameters
557
555
}
558
556
559
- func (c * workflowCompiler ) getTaskRetryParametersWithValues (name string ) []wfapi.Parameter {
560
- retryPolicy := c . getTaskRetryPolicySpec ( name )
557
+ func (c * workflowCompiler ) getTaskRetryParametersWithValues (task * pipelinespec. PipelineTaskSpec ) []wfapi.Parameter {
558
+ retryPolicy := task . GetRetryPolicy ( )
561
559
if retryPolicy == nil {
562
560
return []wfapi.Parameter {}
563
561
}
@@ -609,6 +607,26 @@ func (c *workflowCompiler) addParameterInputPath(parameters []wfapi.Parameter) [
609
607
return parameters
610
608
}
611
609
610
+ func (c * workflowCompiler ) getTaskRetryStrategyFromInput (maxCount string , backOffDuration string , backOffFactor string ,
611
+ backOffMaxDuration string ) * wfapi.RetryStrategy {
612
+ backoff := & wfapi.Backoff {
613
+ Factor : & intstr.IntOrString {
614
+ Type : intstr .String ,
615
+ StrVal : backOffFactor ,
616
+ },
617
+ MaxDuration : backOffMaxDuration ,
618
+ Duration : backOffDuration ,
619
+ }
620
+
621
+ return & wfapi.RetryStrategy {
622
+ Limit : & intstr.IntOrString {
623
+ Type : intstr .String ,
624
+ StrVal : maxCount ,
625
+ },
626
+ Backoff : backoff ,
627
+ }
628
+ }
629
+
612
630
// Extends the PodMetadata to include Kubernetes-specific executor config.
613
631
// Although the current podMetadata object is always empty, this function
614
632
// doesn't overwrite the existing podMetadata because for security reasons
@@ -638,26 +656,6 @@ func extendPodMetadata(
638
656
}
639
657
}
640
658
641
- func (c * workflowCompiler ) getTaskRetryStrategyFromInput (maxCount string , backOffDuration string , backOffFactor string ,
642
- backOffMaxDuration string ) * wfapi.RetryStrategy {
643
- backoff := & wfapi.Backoff {
644
- Factor : & intstr.IntOrString {
645
- Type : intstr .String ,
646
- StrVal : backOffFactor ,
647
- },
648
- MaxDuration : backOffMaxDuration ,
649
- Duration : backOffDuration ,
650
- }
651
-
652
- return & wfapi.RetryStrategy {
653
- Limit : & intstr.IntOrString {
654
- Type : intstr .String ,
655
- StrVal : maxCount ,
656
- },
657
- Backoff : backoff ,
658
- }
659
- }
660
-
661
659
// Extends metadata map values, highPriorityMap should overwrites lowPriorityMap values
662
660
// The original Map inputs should have higher priority since its defined by admin
663
661
// TODO: Use maps.Copy after moving to go 1.21+
0 commit comments