Skip to content

Commit

Permalink
fix(executor): Do not delete local artifacts after upload. Fixes argo…
Browse files Browse the repository at this point in the history
…proj#4676

Signed-off-by: Alex Collins <alex_collins@intuit.com>
  • Loading branch information
alexec committed Dec 10, 2020
1 parent 96a55ce commit 93dbc27
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions workflow/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,16 +340,25 @@ func (we *WorkflowExecutor) saveArtifact(mainCtrID string, art *wfv1.Artifact) e
if err != nil {
return err
}
// remove is best effort (the container will go away anyways).
// we just want reduce peak space usage
err = os.Remove(localArtPath)
if err != nil {
log.Warnf("Failed to remove %s: %v", localArtPath, err)
}
we.maybeDeleteLocalArtPath(localArtPath)
log.Infof("Successfully saved file: %s", localArtPath)
return nil
}

func (we *WorkflowExecutor) maybeDeleteLocalArtPath(localArtPath string) {
if os.Getenv("REMOVE_LOCAL_ART_PATH") == "true" {
log.WithField("localArtPath", localArtPath).Info("deleting local artifact")
// remove is best effort (the container will go away anyways).
// we just want reduce peak space usage
err := os.Remove(localArtPath)
if err != nil {
log.Warnf("Failed to remove %s: %v", localArtPath, err)
}
} else {
log.WithField("localArtPath", localArtPath).Info("not deleting local artifact")
}
}

// stageArchiveFile stages a path in a container for archiving from the wait sidecar.
// Returns a filename and a local path for the upload.
// The filename is incorporated into the final path when uploading it to the artifact repo.
Expand Down

0 comments on commit 93dbc27

Please sign in to comment.