ls/cp/mirror: Ignore objects with StorageClass GLACIER. (#1742)

Fixes #1741
This commit is contained in:
Harshavardhana
2016-06-23 00:28:17 -07:00
committed by Anand Babu (AB) Periasamy
parent 17468c8863
commit 2d431dacbc
7 changed files with 43 additions and 3 deletions
+9
View File
@@ -74,6 +74,15 @@ func (e ObjectAlreadyExists) Error() string {
return "Object ‘" + e.Object + "’ already exists."
}
// ObjectOnGlacier - object is of storage class glacier.
type ObjectOnGlacier struct {
Object string
}
func (e ObjectOnGlacier) Error() string {
return "Object ‘" + e.Object + "’ is on Glacier storage."
}
// BucketNameTopLevel - generic error
type BucketNameTopLevel struct{}
+20
View File
@@ -678,6 +678,19 @@ func (c *s3Client) listInRoutine(contentCh chan *clientContent) {
}
}
// S3 offers a range of storage classes designed for
// different use cases, following list captures these.
const (
// General purpose.
// s3StorageClassStandard = "STANDARD"
// Infrequent access.
// s3StorageClassInfrequent = "STANDARD_IA"
// Reduced redundancy access.
// s3StorageClassRedundancy = "REDUCED_REDUNDANCY"
// Archive access.
s3StorageClassGlacier = "GLACIER"
)
func (c *s3Client) listRecursiveInRoutine(contentCh chan *clientContent) {
defer close(contentCh)
// get bucket and object from URL.
@@ -701,6 +714,13 @@ func (c *s3Client) listRecursiveInRoutine(contentCh chan *clientContent) {
}
isRecursive := true
for object := range c.api.ListObjects(bucket.Name, o, isRecursive, nil) {
// Return error if we encountered glacier object and continue.
if object.StorageClass == s3StorageClassGlacier {
contentCh <- &clientContent{
Err: probe.NewError(ObjectOnGlacier{object.Key}),
}
continue
}
if object.Err != nil {
contentCh <- &clientContent{
Err: probe.NewError(object.Err),
+2 -1
View File
@@ -351,7 +351,8 @@ func doCopySession(session *sessionV7) {
// Handle this specifically for filesystem related errors.
case BrokenSymlink, TooManyLevelsSymlink, PathNotFound, PathInsufficientPermission:
continue
case BucketNameEmpty, ObjectMissing, ObjectAlreadyExists, BucketDoesNotExist, BucketInvalid:
// Handle these specifically for object storage related errors.
case BucketNameEmpty, ObjectMissing, ObjectAlreadyExists, BucketDoesNotExist, BucketInvalid, ObjectOnGlacier:
continue
}
// For critical errors we should exit. Session
+6
View File
@@ -86,6 +86,9 @@ func objectDifference(sourceClnt, targetClnt Client, sourceURL, targetURL string
// Handle this specifically for filesystem related errors.
case BrokenSymlink, TooManyLevelsSymlink, PathNotFound, PathInsufficientPermission:
errorIf(srcCtnt.Err.Trace(sourceURL, targetURL), fmt.Sprintf("Failed on '%s'", sourceURL))
// Handle these specifically for object storage related errors.
case BucketNameEmpty, ObjectMissing, ObjectAlreadyExists, BucketDoesNotExist, BucketInvalid, ObjectOnGlacier:
errorIf(srcCtnt.Err.Trace(sourceURL, targetURL), fmt.Sprintf("Failed on '%s'", sourceURL))
default:
fatalIf(srcCtnt.Err.Trace(sourceURL, targetURL), fmt.Sprintf("Failed on '%s'", sourceURL))
}
@@ -98,6 +101,9 @@ func objectDifference(sourceClnt, targetClnt Client, sourceURL, targetURL string
// Handle this specifically for filesystem related errors.
case BrokenSymlink, TooManyLevelsSymlink, PathNotFound, PathInsufficientPermission:
errorIf(tgtCtnt.Err.Trace(sourceURL, targetURL), fmt.Sprintf("Failed on '%s'", targetURL))
// Handle these specifically for object storage related errors.
case BucketNameEmpty, ObjectMissing, ObjectAlreadyExists, BucketDoesNotExist, BucketInvalid, ObjectOnGlacier:
errorIf(tgtCtnt.Err.Trace(sourceURL, targetURL), fmt.Sprintf("Failed on '%s'", targetURL))
default:
fatalIf(tgtCtnt.Err.Trace(sourceURL, targetURL), fmt.Sprintf("Failed on '%s'", targetURL))
}
+1 -1
View File
@@ -37,7 +37,7 @@ var (
},
cli.BoolFlag{
Name: "incomplete, I",
Usage: "Remove incomplete uploads.",
Usage: "List incomplete uploads.",
},
}
)
+3
View File
@@ -126,6 +126,9 @@ func doList(clnt Client, isRecursive, isIncomplete bool) *probe.Error {
case PathInsufficientPermission:
errorIf(content.Err.Trace(clnt.GetURL().String()), "Unable to list folder.")
continue
case ObjectOnGlacier:
errorIf(content.Err.Trace(clnt.GetURL().String()), "")
continue
}
errorIf(content.Err.Trace(clnt.GetURL().String()), "Unable to list folder.")
continue
+2 -1
View File
@@ -408,7 +408,8 @@ func doMirrorSession(session *sessionV7) {
// Handle this specifically for filesystem related errors.
case BrokenSymlink, TooManyLevelsSymlink, PathNotFound, PathInsufficientPermission:
continue
case BucketNameEmpty, ObjectMissing, ObjectAlreadyExists, BucketDoesNotExist, BucketInvalid:
// Handle this specifically for object storage related errors.
case BucketNameEmpty, ObjectMissing, ObjectAlreadyExists, BucketDoesNotExist, BucketInvalid, ObjectOnGlacier:
continue
}
// For critical errors we should exit. Session