Skip to content
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 global artifact overwriting in nested workflow #1086

Merged
merged 10 commits into from
Jan 3, 2019
10 changes: 8 additions & 2 deletions workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ func (woc *wfOperationCtx) addOutputsToScope(prefix string, outputs *wfv1.Output
if scope != nil {
scope.addArtifactToScope(key, art)
}
woc.addArtifactToGlobalScope(art)
woc.addArtifactToGlobalScope(art, scope)
}
}

Expand Down Expand Up @@ -1383,7 +1383,7 @@ func (woc *wfOperationCtx) addParamToGlobalScope(param wfv1.Parameter) {

// addArtifactToGlobalScope exports any desired node outputs to the global scope
// Optionally adds to a local scope if supplied
func (woc *wfOperationCtx) addArtifactToGlobalScope(art wfv1.Artifact) {
func (woc *wfOperationCtx) addArtifactToGlobalScope(art wfv1.Artifact, scope *wfScope) {
if art.GlobalName == "" {
return
}
Expand All @@ -1397,6 +1397,9 @@ func (woc *wfOperationCtx) addArtifactToGlobalScope(art wfv1.Artifact) {
art.Path = ""
if !reflect.DeepEqual(woc.wf.Status.Outputs.Artifacts[i], art) {
woc.wf.Status.Outputs.Artifacts[i] = art
if scope != nil {
scope.addArtifactToScope(globalArtName, art)
}
woc.log.Infof("overwriting %s: %v", globalArtName, art)
woc.updated = true
}
Expand All @@ -1412,6 +1415,9 @@ func (woc *wfOperationCtx) addArtifactToGlobalScope(art wfv1.Artifact) {
art.Path = ""
woc.log.Infof("setting %s: %v", globalArtName, art)
woc.wf.Status.Outputs.Artifacts = append(woc.wf.Status.Outputs.Artifacts, art)
if scope != nil {
scope.addArtifactToScope(globalArtName, art)
}
woc.updated = true
}

Expand Down