From b8ecf333d5c92c2d21fc1699cc0f53d910e5ff1e Mon Sep 17 00:00:00 2001 From: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> Date: Mon, 11 Nov 2024 08:30:46 +1100 Subject: [PATCH 1/3] Signed-off-by: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> --- workflow/artifacts/s3/s3.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/workflow/artifacts/s3/s3.go b/workflow/artifacts/s3/s3.go index 5ce08584bc48..5a51c443ed49 100644 --- a/workflow/artifacts/s3/s3.go +++ b/workflow/artifacts/s3/s3.go @@ -102,6 +102,22 @@ func loadS3Artifact(s3cli argos3.S3Client, inputArtifact *wfv1.Artifact, path st if origErr == nil { return true, nil } + + if strings.Contains(origErr, "fileName is a directory.") { + // Handle directory case by checking if it's a valid directory + isDir, err := s3cli.IsDirectory(inputArtifact.S3.Bucket, inputArtifact.S3.Key) + if err != nil { + return !isTransientS3Err(err), fmt.Errorf("failed to test if %s is a directory: %v", inputArtifact.S3.Key, err) + } + if isDir { + // Proceed to get the directory contents if it's actually a directory + if err := s3cli.GetDirectory(inputArtifact.S3.Bucket, inputArtifact.S3.Key, path); err != nil { + return !isTransientS3Err(err), fmt.Errorf("failed to get directory: %v", err) + } + return true, nil + } + } + if !argos3.IsS3ErrCode(origErr, "NoSuchKey") { return !isTransientS3Err(origErr), fmt.Errorf("failed to get file: %v", origErr) } From e06dd69c462afbfa19d5b96c4ec9d506250a8c09 Mon Sep 17 00:00:00 2001 From: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> Date: Mon, 11 Nov 2024 08:39:32 +1100 Subject: [PATCH 2/3] Signed-off-by: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> --- workflow/artifacts/s3/s3.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow/artifacts/s3/s3.go b/workflow/artifacts/s3/s3.go index 5a51c443ed49..cfec6fe960bb 100644 --- a/workflow/artifacts/s3/s3.go +++ b/workflow/artifacts/s3/s3.go @@ -103,7 +103,7 @@ func loadS3Artifact(s3cli argos3.S3Client, inputArtifact *wfv1.Artifact, path st return true, nil } - if strings.Contains(origErr, "fileName is a directory.") { + if strings.Contains(origErr.Error(), "fileName is a directory.") { // Handle directory case by checking if it's a valid directory isDir, err := s3cli.IsDirectory(inputArtifact.S3.Bucket, inputArtifact.S3.Key) if err != nil { From defe1e85f855124de73ff18e5cc1768ae13cd53e Mon Sep 17 00:00:00 2001 From: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> Date: Mon, 11 Nov 2024 20:26:36 +1100 Subject: [PATCH 3/3] Signed-off-by: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> --- workflow/artifacts/s3/s3.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workflow/artifacts/s3/s3.go b/workflow/artifacts/s3/s3.go index cfec6fe960bb..dd4689d0da83 100644 --- a/workflow/artifacts/s3/s3.go +++ b/workflow/artifacts/s3/s3.go @@ -102,7 +102,7 @@ func loadS3Artifact(s3cli argos3.S3Client, inputArtifact *wfv1.Artifact, path st if origErr == nil { return true, nil } - + if strings.Contains(origErr.Error(), "fileName is a directory.") { // Handle directory case by checking if it's a valid directory isDir, err := s3cli.IsDirectory(inputArtifact.S3.Bucket, inputArtifact.S3.Key) @@ -117,7 +117,7 @@ func loadS3Artifact(s3cli argos3.S3Client, inputArtifact *wfv1.Artifact, path st return true, nil } } - + if !argos3.IsS3ErrCode(origErr, "NoSuchKey") { return !isTransientS3Err(origErr), fmt.Errorf("failed to get file: %v", origErr) }