Continue listing upon error during diff and mirror (#2988)
This commit is contained in:
committed by
kannappanr
parent
c5112d4a0f
commit
69bea2eb96
+7
-13
@@ -1497,7 +1497,7 @@ func (c *s3Client) listIncompleteInRoutine(contentCh chan *clientContent) {
|
||||
contentCh <- &clientContent{
|
||||
Err: probe.NewError(object.Err),
|
||||
}
|
||||
continue
|
||||
return
|
||||
}
|
||||
content := &clientContent{}
|
||||
url := *c.targetURL
|
||||
@@ -1525,7 +1525,7 @@ func (c *s3Client) listIncompleteInRoutine(contentCh chan *clientContent) {
|
||||
contentCh <- &clientContent{
|
||||
Err: probe.NewError(object.Err),
|
||||
}
|
||||
continue
|
||||
return
|
||||
}
|
||||
content := &clientContent{}
|
||||
url := *c.targetURL
|
||||
@@ -1568,7 +1568,7 @@ func (c *s3Client) listIncompleteRecursiveInRoutine(contentCh chan *clientConten
|
||||
contentCh <- &clientContent{
|
||||
Err: probe.NewError(object.Err),
|
||||
}
|
||||
continue
|
||||
return
|
||||
}
|
||||
url := *c.targetURL
|
||||
url.Path = c.joinPath(bucket.Name, object.Key)
|
||||
@@ -1587,7 +1587,7 @@ func (c *s3Client) listIncompleteRecursiveInRoutine(contentCh chan *clientConten
|
||||
contentCh <- &clientContent{
|
||||
Err: probe.NewError(object.Err),
|
||||
}
|
||||
continue
|
||||
return
|
||||
}
|
||||
url := *c.targetURL
|
||||
// Join bucket and incoming object key.
|
||||
@@ -1943,23 +1943,17 @@ func (c *s3Client) listRecursiveInRoutine(contentCh chan *clientContent, metadat
|
||||
for _, bucket := range buckets {
|
||||
isRecursive := true
|
||||
for object := range c.listObjectWrapper(bucket.Name, o, isRecursive, nil, metadata) {
|
||||
// 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),
|
||||
}
|
||||
continue
|
||||
return
|
||||
}
|
||||
content := &clientContent{}
|
||||
objectURL := *c.targetURL
|
||||
objectURL.Path = c.joinPath(bucket.Name, object.Key)
|
||||
content.URL = objectURL
|
||||
content.StorageClass = object.StorageClass
|
||||
content.Size = object.Size
|
||||
content.ETag = object.ETag
|
||||
content.Time = object.LastModified
|
||||
@@ -1974,7 +1968,7 @@ func (c *s3Client) listRecursiveInRoutine(contentCh chan *clientContent, metadat
|
||||
contentCh <- &clientContent{
|
||||
Err: probe.NewError(object.Err),
|
||||
}
|
||||
continue
|
||||
return
|
||||
}
|
||||
content := &clientContent{}
|
||||
url := *c.targetURL
|
||||
|
||||
@@ -90,6 +90,7 @@ type clientContent struct {
|
||||
Time time.Time
|
||||
Size int64
|
||||
Type os.FileMode
|
||||
StorageClass string
|
||||
Metadata map[string]string
|
||||
UserMetadata map[string]string
|
||||
ETag string
|
||||
|
||||
@@ -88,8 +88,6 @@ func (d diffMessage) String() string {
|
||||
msg = console.Colorize("DiffType", "! "+d.SecondURL)
|
||||
case differInSize:
|
||||
msg = console.Colorize("DiffSize", "! "+d.SecondURL)
|
||||
case differInTime:
|
||||
msg = console.Colorize("DiffTime", "! "+d.SecondURL)
|
||||
case differInMetadata:
|
||||
msg = console.Colorize("DiffMetadata", "! "+d.SecondURL)
|
||||
default:
|
||||
|
||||
+157
-153
@@ -19,10 +19,13 @@ package cmd
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
// golang does not support flat keys for path matching, find does
|
||||
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/minio-go/v6"
|
||||
"golang.org/x/text/unicode/norm"
|
||||
)
|
||||
|
||||
@@ -32,7 +35,6 @@ type differType int
|
||||
const (
|
||||
differInNone differType = iota // does not differ
|
||||
differInSize // differs in size
|
||||
differInTime // differs in time
|
||||
differInMetadata // differs in metadata
|
||||
differInType // differs in type, exfile/directory
|
||||
differInFirst // only in source (FIRST)
|
||||
@@ -45,8 +47,6 @@ func (d differType) String() string {
|
||||
return ""
|
||||
case differInSize:
|
||||
return "size"
|
||||
case differInTime:
|
||||
return "time"
|
||||
case differInMetadata:
|
||||
return "metadata"
|
||||
case differInType:
|
||||
@@ -67,167 +67,38 @@ func dirDifference(sourceClnt, targetClnt Client, sourceURL, targetURL string) (
|
||||
return difference(sourceClnt, targetClnt, sourceURL, targetURL, false, false, true, DirFirst)
|
||||
}
|
||||
|
||||
// objectDifference function finds the difference between all objects
|
||||
// recursively in sorted order from source and target.
|
||||
func difference(sourceClnt, targetClnt Client, sourceURL, targetURL string, isMetadata bool, isRecursive, returnSimilar bool, dirOpt DirOpt) (diffCh chan diffMessage) {
|
||||
var (
|
||||
srcEOF, tgtEOF bool
|
||||
srcOk, tgtOk bool
|
||||
srcCtnt, tgtCtnt *clientContent
|
||||
srcSuffix, tgtSuffix string
|
||||
)
|
||||
|
||||
func differenceInternal(sourceClnt, targetClnt Client, sourceURL, targetURL string, isMetadata bool, isRecursive, returnSimilar bool, dirOpt DirOpt, diffCh chan<- diffMessage) *probe.Error {
|
||||
// Set default values for listing.
|
||||
isIncomplete := false // we will not compare any incomplete objects.
|
||||
srcCh := sourceClnt.List(isRecursive, isIncomplete, isMetadata, dirOpt)
|
||||
tgtCh := targetClnt.List(isRecursive, isIncomplete, isMetadata, dirOpt)
|
||||
|
||||
diffCh = make(chan diffMessage, 10000)
|
||||
srcCtnt, srcOk := <-srcCh
|
||||
tgtCtnt, tgtOk := <-tgtCh
|
||||
|
||||
go func() {
|
||||
var (
|
||||
srcEOF, tgtEOF bool
|
||||
)
|
||||
|
||||
srcCtnt, srcOk = <-srcCh
|
||||
tgtCtnt, tgtOk = <-tgtCh
|
||||
for {
|
||||
srcEOF = !srcOk
|
||||
tgtEOF = !tgtOk
|
||||
|
||||
defer close(diffCh)
|
||||
// No objects from source AND target: Finish
|
||||
if srcEOF && tgtEOF {
|
||||
break
|
||||
}
|
||||
|
||||
for {
|
||||
srcEOF = !srcOk
|
||||
tgtEOF = !tgtOk
|
||||
if !srcEOF && srcCtnt.Err != nil {
|
||||
return srcCtnt.Err.Trace(sourceURL, targetURL)
|
||||
}
|
||||
|
||||
// No objects from source AND target: Finish
|
||||
if srcEOF && tgtEOF {
|
||||
break
|
||||
}
|
||||
if !tgtEOF && tgtCtnt.Err != nil {
|
||||
return tgtCtnt.Err.Trace(sourceURL, targetURL)
|
||||
}
|
||||
|
||||
if !srcEOF && srcCtnt.Err != nil {
|
||||
diffCh <- diffMessage{Error: srcCtnt.Err.Trace(sourceURL, targetURL)}
|
||||
return
|
||||
}
|
||||
|
||||
if !tgtEOF && tgtCtnt.Err != nil {
|
||||
diffCh <- diffMessage{Error: tgtCtnt.Err.Trace(sourceURL, targetURL)}
|
||||
return
|
||||
}
|
||||
|
||||
// If source doesn't have objects anymore, comparison becomes obvious
|
||||
if srcEOF {
|
||||
diffCh <- diffMessage{
|
||||
SecondURL: tgtCtnt.URL.String(),
|
||||
Diff: differInSecond,
|
||||
secondContent: tgtCtnt,
|
||||
}
|
||||
tgtCtnt, tgtOk = <-tgtCh
|
||||
continue
|
||||
}
|
||||
|
||||
// The same for target
|
||||
if tgtEOF {
|
||||
diffCh <- diffMessage{
|
||||
FirstURL: srcCtnt.URL.String(),
|
||||
Diff: differInFirst,
|
||||
firstContent: srcCtnt,
|
||||
}
|
||||
srcCtnt, srcOk = <-srcCh
|
||||
continue
|
||||
}
|
||||
|
||||
srcSuffix = strings.TrimPrefix(srcCtnt.URL.String(), sourceURL)
|
||||
tgtSuffix = strings.TrimPrefix(tgtCtnt.URL.String(), targetURL)
|
||||
|
||||
current := urlJoinPath(targetURL, srcSuffix)
|
||||
expected := urlJoinPath(targetURL, tgtSuffix)
|
||||
|
||||
if !utf8.ValidString(srcSuffix) {
|
||||
// Error. Keys must be valid UTF-8.
|
||||
diffCh <- diffMessage{Error: errInvalidSource(current).Trace()}
|
||||
srcCtnt, srcOk = <-srcCh
|
||||
continue
|
||||
}
|
||||
if !utf8.ValidString(tgtSuffix) {
|
||||
// Error. Keys must be valid UTF-8.
|
||||
diffCh <- diffMessage{Error: errInvalidTarget(expected).Trace()}
|
||||
tgtCtnt, tgtOk = <-tgtCh
|
||||
continue
|
||||
}
|
||||
|
||||
// Normalize to avoid situations where multiple byte representations are possible.
|
||||
// e.g. 'ä' can be represented as precomposed U+00E4 (UTF-8 0xc3a4) or decomposed
|
||||
// U+0061 U+0308 (UTF-8 0x61cc88).
|
||||
normalizedCurrent := norm.NFC.String(current)
|
||||
normalizedExpected := norm.NFC.String(expected)
|
||||
|
||||
if normalizedExpected > normalizedCurrent {
|
||||
diffCh <- diffMessage{
|
||||
FirstURL: srcCtnt.URL.String(),
|
||||
Diff: differInFirst,
|
||||
firstContent: srcCtnt,
|
||||
}
|
||||
srcCtnt, srcOk = <-srcCh
|
||||
continue
|
||||
}
|
||||
if normalizedExpected == normalizedCurrent {
|
||||
srcType, tgtType := srcCtnt.Type, tgtCtnt.Type
|
||||
srcSize, tgtSize := srcCtnt.Size, tgtCtnt.Size
|
||||
srcTime, tgtTime := srcCtnt.Time, tgtCtnt.Time
|
||||
if srcType.IsRegular() && !tgtType.IsRegular() ||
|
||||
!srcType.IsRegular() && tgtType.IsRegular() {
|
||||
// Type differs. Source is never a directory.
|
||||
diffCh <- diffMessage{
|
||||
FirstURL: srcCtnt.URL.String(),
|
||||
SecondURL: tgtCtnt.URL.String(),
|
||||
Diff: differInType,
|
||||
firstContent: srcCtnt,
|
||||
secondContent: tgtCtnt,
|
||||
}
|
||||
continue
|
||||
}
|
||||
if (srcType.IsRegular() && tgtType.IsRegular()) && srcSize != tgtSize {
|
||||
// Regular files differing in size.
|
||||
diffCh <- diffMessage{
|
||||
FirstURL: srcCtnt.URL.String(),
|
||||
SecondURL: tgtCtnt.URL.String(),
|
||||
Diff: differInSize,
|
||||
firstContent: srcCtnt,
|
||||
secondContent: tgtCtnt,
|
||||
}
|
||||
} else if isMetadata &&
|
||||
!reflect.DeepEqual(srcCtnt.UserMetadata, tgtCtnt.UserMetadata) &&
|
||||
!reflect.DeepEqual(srcCtnt.Metadata, tgtCtnt.Metadata) {
|
||||
|
||||
// Regular files user requesting additional metadata to same file.
|
||||
diffCh <- diffMessage{
|
||||
FirstURL: srcCtnt.URL.String(),
|
||||
SecondURL: tgtCtnt.URL.String(),
|
||||
Diff: differInMetadata,
|
||||
firstContent: srcCtnt,
|
||||
secondContent: tgtCtnt,
|
||||
}
|
||||
} else if srcTime.After(tgtTime) {
|
||||
// Regular files differing in timestamp.
|
||||
diffCh <- diffMessage{
|
||||
FirstURL: srcCtnt.URL.String(),
|
||||
SecondURL: tgtCtnt.URL.String(),
|
||||
Diff: differInTime,
|
||||
firstContent: srcCtnt,
|
||||
secondContent: tgtCtnt,
|
||||
}
|
||||
}
|
||||
// No differ
|
||||
if returnSimilar {
|
||||
diffCh <- diffMessage{
|
||||
FirstURL: srcCtnt.URL.String(),
|
||||
SecondURL: tgtCtnt.URL.String(),
|
||||
Diff: differInNone,
|
||||
firstContent: srcCtnt,
|
||||
secondContent: tgtCtnt,
|
||||
}
|
||||
}
|
||||
srcCtnt, srcOk = <-srcCh
|
||||
tgtCtnt, tgtOk = <-tgtCh
|
||||
continue
|
||||
}
|
||||
// Differ in second
|
||||
// If source doesn't have objects anymore, comparison becomes obvious
|
||||
if srcEOF {
|
||||
diffCh <- diffMessage{
|
||||
SecondURL: tgtCtnt.URL.String(),
|
||||
Diff: differInSecond,
|
||||
@@ -236,6 +107,139 @@ func difference(sourceClnt, targetClnt Client, sourceURL, targetURL string, isMe
|
||||
tgtCtnt, tgtOk = <-tgtCh
|
||||
continue
|
||||
}
|
||||
|
||||
// The same for target
|
||||
if tgtEOF {
|
||||
diffCh <- diffMessage{
|
||||
FirstURL: srcCtnt.URL.String(),
|
||||
Diff: differInFirst,
|
||||
firstContent: srcCtnt,
|
||||
}
|
||||
srcCtnt, srcOk = <-srcCh
|
||||
continue
|
||||
}
|
||||
|
||||
srcSuffix := strings.TrimPrefix(srcCtnt.URL.String(), sourceURL)
|
||||
tgtSuffix := strings.TrimPrefix(tgtCtnt.URL.String(), targetURL)
|
||||
|
||||
current := urlJoinPath(targetURL, srcSuffix)
|
||||
expected := urlJoinPath(targetURL, tgtSuffix)
|
||||
|
||||
if !utf8.ValidString(srcSuffix) {
|
||||
// Error. Keys must be valid UTF-8.
|
||||
diffCh <- diffMessage{Error: errInvalidSource(current).Trace()}
|
||||
srcCtnt, srcOk = <-srcCh
|
||||
continue
|
||||
}
|
||||
if !utf8.ValidString(tgtSuffix) {
|
||||
// Error. Keys must be valid UTF-8.
|
||||
diffCh <- diffMessage{Error: errInvalidTarget(expected).Trace()}
|
||||
tgtCtnt, tgtOk = <-tgtCh
|
||||
continue
|
||||
}
|
||||
|
||||
// Normalize to avoid situations where multiple byte representations are possible.
|
||||
// e.g. 'ä' can be represented as precomposed U+00E4 (UTF-8 0xc3a4) or decomposed
|
||||
// U+0061 U+0308 (UTF-8 0x61cc88).
|
||||
normalizedCurrent := norm.NFC.String(current)
|
||||
normalizedExpected := norm.NFC.String(expected)
|
||||
|
||||
if normalizedExpected > normalizedCurrent {
|
||||
diffCh <- diffMessage{
|
||||
FirstURL: srcCtnt.URL.String(),
|
||||
Diff: differInFirst,
|
||||
firstContent: srcCtnt,
|
||||
}
|
||||
srcCtnt, srcOk = <-srcCh
|
||||
continue
|
||||
}
|
||||
if normalizedExpected == normalizedCurrent {
|
||||
srcType, tgtType := srcCtnt.Type, tgtCtnt.Type
|
||||
srcSize, tgtSize := srcCtnt.Size, tgtCtnt.Size
|
||||
if srcType.IsRegular() && !tgtType.IsRegular() ||
|
||||
!srcType.IsRegular() && tgtType.IsRegular() {
|
||||
// Type differs. Source is never a directory.
|
||||
diffCh <- diffMessage{
|
||||
FirstURL: srcCtnt.URL.String(),
|
||||
SecondURL: tgtCtnt.URL.String(),
|
||||
Diff: differInType,
|
||||
firstContent: srcCtnt,
|
||||
secondContent: tgtCtnt,
|
||||
}
|
||||
continue
|
||||
}
|
||||
if (srcType.IsRegular() && tgtType.IsRegular()) && srcSize != tgtSize {
|
||||
// Regular files differing in size.
|
||||
diffCh <- diffMessage{
|
||||
FirstURL: srcCtnt.URL.String(),
|
||||
SecondURL: tgtCtnt.URL.String(),
|
||||
Diff: differInSize,
|
||||
firstContent: srcCtnt,
|
||||
secondContent: tgtCtnt,
|
||||
}
|
||||
} else if isMetadata &&
|
||||
!reflect.DeepEqual(srcCtnt.UserMetadata, tgtCtnt.UserMetadata) &&
|
||||
!reflect.DeepEqual(srcCtnt.Metadata, tgtCtnt.Metadata) {
|
||||
|
||||
// Regular files user requesting additional metadata to same file.
|
||||
diffCh <- diffMessage{
|
||||
FirstURL: srcCtnt.URL.String(),
|
||||
SecondURL: tgtCtnt.URL.String(),
|
||||
Diff: differInMetadata,
|
||||
firstContent: srcCtnt,
|
||||
secondContent: tgtCtnt,
|
||||
}
|
||||
}
|
||||
|
||||
// No differ
|
||||
if returnSimilar {
|
||||
diffCh <- diffMessage{
|
||||
FirstURL: srcCtnt.URL.String(),
|
||||
SecondURL: tgtCtnt.URL.String(),
|
||||
Diff: differInNone,
|
||||
firstContent: srcCtnt,
|
||||
secondContent: tgtCtnt,
|
||||
}
|
||||
}
|
||||
srcCtnt, srcOk = <-srcCh
|
||||
tgtCtnt, tgtOk = <-tgtCh
|
||||
continue
|
||||
}
|
||||
// Differ in second
|
||||
diffCh <- diffMessage{
|
||||
SecondURL: tgtCtnt.URL.String(),
|
||||
Diff: differInSecond,
|
||||
secondContent: tgtCtnt,
|
||||
}
|
||||
tgtCtnt, tgtOk = <-tgtCh
|
||||
continue
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// objectDifference function finds the difference between all objects
|
||||
// recursively in sorted order from source and target.
|
||||
func difference(sourceClnt, targetClnt Client, sourceURL, targetURL string, isMetadata bool, isRecursive, returnSimilar bool, dirOpt DirOpt) (diffCh chan diffMessage) {
|
||||
diffCh = make(chan diffMessage, 10000)
|
||||
|
||||
go func() {
|
||||
defer close(diffCh)
|
||||
|
||||
doneCh := make(chan struct{}, 1)
|
||||
defer close(doneCh)
|
||||
|
||||
for range newRetryTimerContinous(time.Second, time.Second*30, minio.MaxJitter, doneCh) {
|
||||
err := differenceInternal(sourceClnt, targetClnt, sourceURL, targetURL,
|
||||
isMetadata, isRecursive, returnSimilar, dirOpt, diffCh)
|
||||
if err != nil {
|
||||
errorIf(err, "Unable to list comparison retrying..")
|
||||
} else {
|
||||
// Success.
|
||||
break
|
||||
}
|
||||
|
||||
}
|
||||
}()
|
||||
|
||||
return diffCh
|
||||
|
||||
+3
-3
@@ -266,13 +266,13 @@ func doFind(ctx *findContext) error {
|
||||
case PathInsufficientPermission:
|
||||
errorIf(content.Err.Trace(ctx.clnt.GetURL().String()), "Unable to list folder.")
|
||||
continue
|
||||
case ObjectOnGlacier:
|
||||
errorIf(content.Err.Trace(ctx.clnt.GetURL().String()), "")
|
||||
continue
|
||||
}
|
||||
fatalIf(content.Err.Trace(ctx.clnt.GetURL().String()), "Unable to list folder.")
|
||||
continue
|
||||
}
|
||||
if content.StorageClass == s3StorageClassGlacier {
|
||||
continue
|
||||
}
|
||||
|
||||
fileKeyName := getAliasedPath(ctx, content.URL.String())
|
||||
fileContent := contentMessage{
|
||||
|
||||
@@ -128,14 +128,16 @@ func doList(clnt Client, isRecursive, isIncomplete bool) 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.")
|
||||
cErr = exitStatus(globalErrorExitStatus) // Set the exit status.
|
||||
continue
|
||||
}
|
||||
|
||||
if content.StorageClass == s3StorageClassGlacier {
|
||||
continue
|
||||
}
|
||||
|
||||
// Convert any os specific delimiters to "/".
|
||||
contentURL := filepath.ToSlash(content.URL.Path)
|
||||
prefixPath = filepath.ToSlash(prefixPath)
|
||||
|
||||
+1
-1
@@ -149,7 +149,7 @@ func deltaSourceTarget(sourceURL, targetURL string, isFake, isOverwrite, isRemov
|
||||
// No difference, continue.
|
||||
case differInType:
|
||||
URLsCh <- URLs{Error: errInvalidTarget(diffMsg.SecondURL)}
|
||||
case differInSize, differInTime, differInMetadata:
|
||||
case differInSize, differInMetadata:
|
||||
if !isOverwrite && !isFake {
|
||||
// Size or time differs but --overwrite not set.
|
||||
URLsCh <- URLs{Error: errOverWriteNotAllowed(diffMsg.SecondURL)}
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* MinIO Go Library for Amazon S3 Compatible Cloud Storage
|
||||
* Copyright 2015-2017 MinIO, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/minio/minio-go/v6"
|
||||
)
|
||||
|
||||
// lockedRandSource provides protected rand source, implements rand.Source interface.
|
||||
type lockedRandSource struct {
|
||||
lk sync.Mutex
|
||||
src rand.Source
|
||||
}
|
||||
|
||||
// Int63 returns a non-negative pseudo-random 63-bit integer as an int64.
|
||||
func (r *lockedRandSource) Int63() (n int64) {
|
||||
r.lk.Lock()
|
||||
n = r.src.Int63()
|
||||
r.lk.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
// Seed uses the provided seed value to initialize the generator to a
|
||||
// deterministic state.
|
||||
func (r *lockedRandSource) Seed(seed int64) {
|
||||
r.lk.Lock()
|
||||
r.src.Seed(seed)
|
||||
r.lk.Unlock()
|
||||
}
|
||||
|
||||
// Introduce a new locked random seed.
|
||||
var random = rand.New(&lockedRandSource{src: rand.NewSource(time.Now().UTC().UnixNano())})
|
||||
|
||||
// newRetryTimerContinous creates a timer with exponentially increasing delays forever.
|
||||
func newRetryTimerContinous(unit time.Duration, cap time.Duration, jitter float64, doneCh chan struct{}) <-chan int {
|
||||
attemptCh := make(chan int)
|
||||
|
||||
// normalize jitter to the range [0, 1.0]
|
||||
if jitter < minio.NoJitter {
|
||||
jitter = minio.NoJitter
|
||||
}
|
||||
if jitter > minio.MaxJitter {
|
||||
jitter = minio.MaxJitter
|
||||
}
|
||||
|
||||
// computes the exponential backoff duration according to
|
||||
// https://www.awsarchitectureblog.com/2015/03/backoff.html
|
||||
exponentialBackoffWait := func(attempt int) time.Duration {
|
||||
// 1<<uint(attempt) below could overflow, so limit the value of attempt
|
||||
maxAttempt := 30
|
||||
if attempt > maxAttempt {
|
||||
attempt = maxAttempt
|
||||
}
|
||||
//sleep = random_between(0, min(cap, base * 2 ** attempt))
|
||||
sleep := unit * time.Duration(1<<uint(attempt))
|
||||
if sleep > cap {
|
||||
sleep = cap
|
||||
}
|
||||
if jitter != minio.NoJitter {
|
||||
sleep -= time.Duration(random.Float64() * float64(sleep) * jitter)
|
||||
}
|
||||
return sleep
|
||||
}
|
||||
|
||||
go func() {
|
||||
defer close(attemptCh)
|
||||
var nextBackoff int
|
||||
for {
|
||||
select {
|
||||
// Attempts starts.
|
||||
case attemptCh <- nextBackoff:
|
||||
nextBackoff++
|
||||
case <-doneCh:
|
||||
// Stop the routine.
|
||||
return
|
||||
}
|
||||
time.Sleep(exponentialBackoffWait(nextBackoff))
|
||||
}
|
||||
}()
|
||||
return attemptCh
|
||||
}
|
||||
+5
-3
@@ -150,14 +150,16 @@ func statURL(targetURL string, isIncomplete, isRecursive bool, encKeyDB map[stri
|
||||
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.")
|
||||
cErr = exitStatus(globalErrorExitStatus) // Set the exit status.
|
||||
continue
|
||||
}
|
||||
|
||||
if content.StorageClass == s3StorageClassGlacier {
|
||||
continue
|
||||
}
|
||||
|
||||
url := targetAlias + getKey(content)
|
||||
standardizedURL := getStandardizedURL(targetURL)
|
||||
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ func isErrIgnored(err *probe.Error) (ignored bool) {
|
||||
// Handle these specifically for object storage related errors.
|
||||
case BucketNameEmpty, ObjectMissing, ObjectAlreadyExists:
|
||||
ignored = true
|
||||
case ObjectAlreadyExistsAsDirectory, BucketDoesNotExist, BucketInvalid, ObjectOnGlacier:
|
||||
case ObjectAlreadyExistsAsDirectory, BucketDoesNotExist, BucketInvalid:
|
||||
ignored = true
|
||||
default:
|
||||
ignored = false
|
||||
|
||||
@@ -887,14 +887,14 @@ mc diff minio1/diffbucket minio2/diffbucket --json
|
||||
```
|
||||
|
||||
#### Diff values in json output
|
||||
|Constant| Value | Meaning |
|
||||
| ---------- | ---------- | -------- |
|
||||
|differInNone |0|Does not differ|
|
||||
|differInSize |1|Differs in size|
|
||||
|differInTime |2|Differs in time|
|
||||
|differInType |3|Differs in type exfile/directory|
|
||||
|differInFirst |4|Only in source (FIRST)|
|
||||
|differInSecond |5|Only in target (SECOND)|
|
||||
| Constant | Value | Meaning |
|
||||
| ---------- | ---------- | -------- |
|
||||
| differInNone | 0 | Does not differ |
|
||||
| differInSize | 1 | Differs in size |
|
||||
| differInMetadata | 2 | Differs in metadata |
|
||||
| differInType | 3 | Differs in type exfile/directory |
|
||||
| differInFirst | 4 | Only in source (FIRST) |
|
||||
| differInSecond | 5 | Only in target (SECOND) |
|
||||
|
||||
<a name="watch"></a>
|
||||
### Command `watch` - Watch for files and object storage events.
|
||||
|
||||
Reference in New Issue
Block a user