Skip to content

Commit

Permalink
fix: cleaned key paths in gcs driver. Fixes argoproj#9958 (argoproj#9959
Browse files Browse the repository at this point in the history
)

Signed-off-by: Isitha Subasinghe <[email protected]>
  • Loading branch information
isubasinghe authored Nov 4, 2022
1 parent b91606a commit 6ba1fa5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions workflow/artifacts/gcs/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,15 @@ func newGCSClientDefault() (*storage.Client, error) {
func (g *ArtifactDriver) Load(inputArtifact *wfv1.Artifact, path string) error {
err := waitutil.Backoff(defaultRetry,
func() (bool, error) {
log.Infof("GCS Load path: %s, key: %s", path, inputArtifact.GCS.Key)
key := filepath.Clean(inputArtifact.GCS.Key)
log.Infof("GCS Load path: %s, key: %s", path, key)
gcsClient, err := g.newGCSClient()
if err != nil {
log.Warnf("Failed to create new GCS client: %v", err)
return !isTransientGCSErr(err), err
}
defer gcsClient.Close()
err = downloadObjects(gcsClient, inputArtifact.GCS.Bucket, inputArtifact.GCS.Key, path)
err = downloadObjects(gcsClient, inputArtifact.GCS.Bucket, key, path)
if err != nil {
log.Warnf("Failed to download objects from GCS: %v", err)
return !isTransientGCSErr(err), err
Expand Down Expand Up @@ -210,13 +211,14 @@ func (g *ArtifactDriver) OpenStream(a *wfv1.Artifact) (io.ReadCloser, error) {
func (g *ArtifactDriver) Save(path string, outputArtifact *wfv1.Artifact) error {
err := waitutil.Backoff(defaultRetry,
func() (bool, error) {
log.Infof("GCS Save path: %s, key: %s", path, outputArtifact.GCS.Key)
key := filepath.Clean(outputArtifact.GCS.Key)
log.Infof("GCS Save path: %s, key: %s", path, key)
client, err := g.newGCSClient()
if err != nil {
return !isTransientGCSErr(err), err
}
defer client.Close()
err = uploadObjects(client, outputArtifact.GCS.Bucket, outputArtifact.GCS.Key, path)
err = uploadObjects(client, outputArtifact.GCS.Bucket, key, path)
if err != nil {
return !isTransientGCSErr(err), err
}
Expand Down

0 comments on commit 6ba1fa5

Please sign in to comment.