feat: add skip-errors to mc mirror (#4831)

This commit is contained in:
jiuker
2024-01-25 15:10:12 -08:00
committed by GitHub
parent ffa7a67bcf
commit ffade16689
2 changed files with 13 additions and 3 deletions
+12 -3
View File
@@ -133,6 +133,10 @@ var (
Name: "summary",
Usage: "print a summary of the mirror session",
},
cli.BoolFlag{
Name: "skip-errors",
Usage: "skip any errors when mirroring",
},
}
)
@@ -545,8 +549,12 @@ func (mj *mirrorJob) monitorMirrorStatus(cancel context.CancelFunc) (errDuringMi
ignoreErr = true
}
if !ignoreErr {
errorIf(sURLs.Error.Trace(sURLs.SourceContent.URL.String()),
fmt.Sprintf("Failed to copy `%s`.", sURLs.SourceContent.URL.String()))
if !mj.opts.skipErrors {
errorIf(sURLs.Error.Trace(sURLs.SourceContent.URL.String()),
fmt.Sprintf("Failed to copy `%s`.", sURLs.SourceContent.URL.String()))
} else {
console.Infof("[Warn] Failed to copy `%s`. %s", sURLs.SourceContent.URL.String(), sURLs.Error.Trace(sURLs.SourceContent.URL.String()))
}
}
}
case sURLs.TargetContent != nil:
@@ -569,7 +577,7 @@ func (mj *mirrorJob) monitorMirrorStatus(cancel context.CancelFunc) (errDuringMi
mirrorFailedOps.Inc()
errDuringMirror = true
// Quit mirroring if --watch and --active-active are not passed
if !mj.opts.activeActive && !mj.opts.isWatch {
if !mj.opts.skipErrors && !mj.opts.activeActive && !mj.opts.isWatch {
cancel()
cancelInProgress = true
}
@@ -955,6 +963,7 @@ func runMirror(ctx context.Context, srcURL, dstURL string, cli *cli.Context, enc
isRetriable: cli.Bool("retry"),
md5: cli.Bool("md5"),
disableMultipart: cli.Bool("disable-multipart"),
skipErrors: cli.Bool("skip-errors"),
excludeOptions: cli.StringSlice("exclude"),
excludeStorageClasses: cli.StringSlice("exclude-storageclass"),
olderThan: cli.String("older-than"),
+1
View File
@@ -229,6 +229,7 @@ type mirrorOptions struct {
isWatch, isRemove, isMetadata bool
isRetriable bool
isSummary bool
skipErrors bool
excludeOptions, excludeStorageClasses []string
encKeyDB map[string][]prefixSSEPair
md5, disableMultipart bool