@@ -85,18 +85,6 @@ func (woc *wfOperationCtx) artifactGCStrategiesReady() map[wfv1.ArtifactGCStrate
8585 strategies [wfv1 .ArtifactGCOnWorkflowDeletion ] = struct {}{}
8686 }
8787 }
88- // todo: look at implementing "OnWorkflowSuccessOrDeletion" and "OnWorkflowFailureOrDeletion" instead of these:
89- /*
90- if woc.wf.Status.Successful() {
91- if !woc.wf.Status.ArtifactGCStatus.IsArtifactGCStrategyProcessed(wfv1.ArtifactGCOnWorkflowSuccess) {
92- strategies[wfv1.ArtifactGCOnWorkflowSuccess] = struct{}{}
93- }
94- }
95- if woc.wf.Status.Failed() {
96- if !woc.wf.Status.ArtifactGCStatus.IsArtifactGCStrategyProcessed(wfv1.ArtifactGCOnWorkflowFailure) {
97- strategies[wfv1.ArtifactGCOnWorkflowFailure] = struct{}{}
98- }
99- }*/
10088
10189 return strategies
10290}
@@ -262,10 +250,17 @@ func (woc *wfOperationCtx) artGCTaskName(podName string, taskIndex int) string {
262250 return fmt .Sprintf ("%s-%d" , podName , taskIndex )
263251}
264252
253+ func (woc * wfOperationCtx ) artifactGCPodLabel (podName string ) string {
254+ hashedPod := fnv .New32a ()
255+ _ , _ = hashedPod .Write ([]byte (podName ))
256+ return fmt .Sprintf ("%d" , hashedPod .Sum32 ())
257+ }
258+
265259func (woc * wfOperationCtx ) addTemplateArtifactsToTasks (podName string , tasks * []* wfv1.WorkflowArtifactGCTask , template * wfv1.Template , artifactSearchResults wfv1.ArtifactSearchResults ) {
266260 if len (artifactSearchResults ) == 0 {
267261 return
268262 }
263+
269264 if tasks == nil {
270265 ts := make ([]* wfv1.WorkflowArtifactGCTask , 0 )
271266 tasks = & ts
@@ -282,7 +277,7 @@ func (woc *wfOperationCtx) addTemplateArtifactsToTasks(podName string, tasks *[]
282277 ObjectMeta : metav1.ObjectMeta {
283278 Namespace : woc .wf .Namespace ,
284279 Name : woc .artGCTaskName (podName , 0 ),
285- Labels : map [string ]string {common .LabelKeyArtifactGCPodName : podName },
280+ Labels : map [string ]string {common .LabelKeyArtifactGCPodHash : woc . artifactGCPodLabel ( podName ) },
286281 OwnerReferences : []metav1.OwnerReference { // make sure we get deleted with the workflow
287282 * metav1 .NewControllerRef (woc .wf , wfv1 .SchemeGroupVersion .WithKind (workflow .WorkflowKind )),
288283 },
@@ -416,7 +411,7 @@ func (woc *wfOperationCtx) createArtifactGCPod(ctx context.Context, strategy wfv
416411 ImagePullPolicy : woc .controller .executorImagePullPolicy (),
417412 Args : []string {"artifact" , "delete" , "--loglevel" , getExecutorLogLevel ()},
418413 Env : []corev1.EnvVar {
419- {Name : common .EnvVarArtifactPodName , Value : podName },
414+ {Name : common .EnvVarArtifactGCPodHash , Value : woc . artifactGCPodLabel ( podName ) },
420415 },
421416 // if this pod is breached by an attacker we:
422417 // * prevent installation of any new packages
@@ -547,7 +542,7 @@ func (woc *wfOperationCtx) processCompletedArtifactGCPod(ctx context.Context, po
547542 woc .log .Infof ("processing completed Artifact GC Pod '%s'" , pod .Name )
548543
549544 // get associated WorkflowArtifactGCTasks
550- labelSelector := fmt .Sprintf ("%s = %s" , common .LabelKeyArtifactGCPodName , pod .Name )
545+ labelSelector := fmt .Sprintf ("%s = %s" , common .LabelKeyArtifactGCPodHash , woc . artifactGCPodLabel ( pod .Name ) )
551546 taskList , err := woc .controller .wfclientset .ArgoprojV1alpha1 ().WorkflowArtifactGCTasks (woc .wf .Namespace ).List (ctx , metav1.ListOptions {LabelSelector : labelSelector })
552547 if err != nil {
553548 return fmt .Errorf ("failed to List WorkflowArtifactGCTasks: %w" , err )
0 commit comments