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 ignoring of S3 Glacier type errors bug (#2834) #2846

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions cmd/zc_traverser_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,28 @@ func (t *s3Traverser) Traverse(preprocessor objectMorpher, processor objectProce
return strings.HasSuffix(objectKey, ".") ||
strings.Contains(objectKey, "./")
}

const (
storageClassKey = "X-Amz-Storage-Class"
deepArchiveClass = "DEEP_ARCHIVE"
)

invalidAwsStorageClass := func(minioObject minio.ObjectInfo) bool {
/* S3 object's storage class "DEEP_ARCHIVE" is invalid.
Because S3 Glacier Archive objects cannot be copied to Azure Storage.
*/
storageClasses, ok := minioObject.Metadata[storageClassKey]
if !ok || len(storageClasses) == 0 {
return false
}

storageClass := storageClasses[0]

return storageClass == deepArchiveClass
}

invalidNameErrorMsg := "Skipping S3 object %s, as it is not a valid Blob name. Rename the object and retry the transfer"
invalidAwsStorageClassMsg := "Skipping S3 object %s, as it is not a valid AWS storage class: %s"
// Check if resource is a single object.
if t.s3URLParts.IsObjectSyntactically() && !t.s3URLParts.IsDirectorySyntactically() && !t.s3URLParts.IsBucketSyntactically() {
objectPath := strings.Split(t.s3URLParts.ObjectKey, "/")
Expand All @@ -84,6 +105,12 @@ func (t *s3Traverser) Traverse(preprocessor objectMorpher, processor objectProce
return common.EAzError.InvalidBlobName()
}

if invalidAwsStorageClass(oi) {

WarnStdoutAndScanningLog(fmt.Sprintf(invalidAwsStorageClassMsg, t.s3URLParts.ObjectKey, deepArchiveClass))
return common.EAzError.InvalidAWSStorageClass()
}

// If we actually got object properties, process them.
// Otherwise, treat it as a directory.
// According to IsDirectorySyntactically, objects and folders can share names
Expand Down
5 changes: 4 additions & 1 deletion common/azError.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ func (err AzError) Error() string {

var EAzError AzError

func (err AzError) InvalidAWSStorageClass() AzError {
return AzError{uint64(2), "Invalid AWS Storage Class: ", "DEEP_ARCHIVE"}
}
func (err AzError) LoginCredMissing() AzError {
return AzError{uint64(1), "Login Credentials missing. ", ""}
}
Expand All @@ -67,4 +70,4 @@ func (err AzError) InvalidServiceClient() AzError {

func ErrInvalidClient(msg string) AzError {
return NewAzError(EAzError.InvalidServiceClient(), fmt.Sprintf("Expecting %s client", msg))
}
}