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
fix: use the execWf spec to determine artifactgc strategy #10066
Changes from all commits
ef10af9
fa90417
761011d
8765cdf
c05cf27
7135f3f
ade005d
309dad0
f79b57c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: artgc-from-template-2- | ||
spec: | ||
workflowTemplateRef: | ||
name: artgc-template-2 | ||
clusterScope: false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: artgc-step-wf-tmpl- | ||
spec: | ||
entrypoint: artgc-step-wf-tmpl | ||
templates: | ||
- name: artgc-step-wf-tmpl | ||
steps: | ||
- - name: call-template | ||
templateRef: | ||
name: artgc-template-2 | ||
template: artgc-template | ||
clusterScope: false | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: WorkflowTemplate | ||
metadata: | ||
name: artgc-template-2 | ||
spec: | ||
artifactGC: | ||
strategy: OnWorkflowDeletion | ||
workflowMetadata: | ||
labels: | ||
workflows.argoproj.io/test: "true" | ||
entrypoint: artgc-template | ||
templates: | ||
- name: artgc-template | ||
container: | ||
image: argoproj/argosay:v2 | ||
command: | ||
- sh | ||
- -c | ||
args: | ||
- | | ||
echo "hello world" | ||
echo "hello world" > /tmp/message | ||
outputs: | ||
artifacts: | ||
- name: on-completion | ||
path: /tmp/message | ||
s3: | ||
key: on-completion | ||
bucket: my-bucket-2 | ||
endpoint: minio:9000 | ||
insecure: true | ||
accessKeySecret: | ||
name: my-minio-cred | ||
key: accesskey | ||
secretKeySecret: | ||
name: my-minio-cred | ||
key: secretkey | ||
artifactGC: | ||
strategy: OnWorkflowCompletion | ||
- name: on-deletion | ||
path: /tmp/message | ||
s3: | ||
key: on-deletion | ||
bucket: my-bucket-2 | ||
endpoint: minio:9000 | ||
insecure: true | ||
accessKeySecret: | ||
name: my-minio-cred | ||
key: accesskey | ||
secretKeySecret: | ||
name: my-minio-cred | ||
key: secretkey |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,11 +104,7 @@ func (woc *wfOperationCtx) processArtifactGCStrategy(ctx context.Context, strate | |
woc.log.Debugf("processing Artifact GC Strategy %s", strategy) | ||
|
||
// Search for artifacts | ||
artifactSearchResults := woc.wf.SearchArtifacts(&wfv1.ArtifactSearchQuery{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just change to wow.execWF.SearchArtifacts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tried that at first but the execWf doesn’t seem to include the Workflow Status (for node status). Should it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're correct, you must inspect You should not query across the two. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this look okay then? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @juliev0 Make sure you include the test for workflowdefautls, workflow template There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sarabala1979 I just ran a couple of tests locally to test WorkflowDefaults. In one, I just used a Workflow by itself and verified that it took the default from WorkflowDefaults. In the second, I used a WorkflowTemplate as well. As discussed, since the workflow-controller-configmap is not being dynamically reloaded, it's difficult to test this as part of the e2e test, since otherwise I need to change |
||
ArtifactGCStrategies: map[wfv1.ArtifactGCStrategy]bool{strategy: true}, | ||
Deleted: pointer.BoolPtr(false), | ||
NodeTypes: map[wfv1.NodeType]bool{wfv1.NodeTypePod: true}, | ||
}) | ||
artifactSearchResults := woc.findArtifactsToGC(strategy) | ||
if len(artifactSearchResults) == 0 { | ||
woc.log.Debugf("No Artifact Search Results returned from strategy %s", strategy) | ||
return nil | ||
|
@@ -151,16 +147,16 @@ func (woc *wfOperationCtx) processArtifactGCStrategy(ctx context.Context, strate | |
} | ||
templateName := node.TemplateName | ||
if templateName == "" && node.GetTemplateRef() != nil { | ||
templateName = node.GetTemplateRef().Name | ||
templateName = node.GetTemplateRef().Template | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. was accidentally referring to the WorkflowTemplate's Name here rather than the name of the template within the WorkflowTemplate |
||
if templateName == "" { | ||
return fmt.Errorf("can't process Artifact GC Strategy %s: node %+v has an unnamed template", strategy, node) | ||
} | ||
template, found := templatesByName[templateName] | ||
if !found { | ||
template = woc.wf.GetTemplateByName(templateName) | ||
template = woc.execWf.GetTemplateByName(templateName) | ||
if template == nil { | ||
return fmt.Errorf("can't process Artifact GC Strategy %s: template name %q belonging to node %+v not found??", strategy, node.TemplateName, node) | ||
return fmt.Errorf("can't process Artifact GC Strategy %s: template name %q belonging to node %+v not found??", strategy, templateName, node) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: I confirmed that I no longer see any more cases of |
||
} | ||
templatesByName[templateName] = template | ||
} | ||
|
@@ -538,6 +534,28 @@ func (woc *wfOperationCtx) allArtifactsDeleted() bool { | |
return true | ||
} | ||
|
||
func (woc *wfOperationCtx) findArtifactsToGC(strategy wfv1.ArtifactGCStrategy) wfv1.ArtifactSearchResults { | ||
|
||
var results wfv1.ArtifactSearchResults | ||
|
||
for _, n := range woc.wf.Status.Nodes { | ||
|
||
if n.Type != wfv1.NodeTypePod { | ||
continue | ||
} | ||
for _, a := range n.GetOutputs().GetArtifacts() { | ||
|
||
// artifact strategy is either based on overall Workflow ArtifactGC Strategy, or | ||
// if it's specified on the individual artifact level that takes priority | ||
artifactStrategy := woc.execWf.GetArtifactGCStrategy(&a) | ||
if artifactStrategy == strategy && !a.Deleted { | ||
results = append(results, wfv1.ArtifactSearchResult{Artifact: a, NodeID: n.ID}) | ||
} | ||
} | ||
} | ||
return results | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
|
||
func (woc *wfOperationCtx) processCompletedArtifactGCPod(ctx context.Context, pod *corev1.Pod) error { | ||
woc.log.Infof("processing completed Artifact GC Pod %q", pod.Name) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unlike the WorkflowTemplate test that was already in there, this one includes a strategy specified on the Workflow level