mirror: continue operations even if source object goes missing (#4402)

This commit is contained in:
Anis Elleuch
2022-12-12 12:09:42 -08:00
committed by GitHub
parent c18faa5ff6
commit b8974e5aed
+13 -9
View File
@@ -496,19 +496,20 @@ func (mj *mirrorJob) monitorMirrorStatus(cancel context.CancelFunc) (errDuringMi
mirrorTotalOps.Inc()
if sURLs.Error != nil {
mirrorFailedOps.Inc()
var ignoreErr bool
switch {
case sURLs.SourceContent != nil:
if !isErrIgnored(sURLs.Error) {
if isErrIgnored(sURLs.Error) {
ignoreErr = true
} else {
errorIf(sURLs.Error.Trace(sURLs.SourceContent.URL.String()),
fmt.Sprintf("Failed to copy `%s`.", sURLs.SourceContent.URL.String()))
errDuringMirror = true
}
case sURLs.TargetContent != nil:
// When sURLs.SourceContent is nil, we know that we have an error related to removing
errorIf(sURLs.Error.Trace(sURLs.TargetContent.URL.String()),
fmt.Sprintf("Failed to remove `%s`.", sURLs.TargetContent.URL.String()))
errDuringMirror = true
default:
if sURLs.ErrorCond == differInUnknown {
errorIf(sURLs.Error.Trace(), "Failed to perform mirroring")
@@ -516,13 +517,16 @@ func (mj *mirrorJob) monitorMirrorStatus(cancel context.CancelFunc) (errDuringMi
errorIf(sURLs.Error.Trace(),
"Failed to perform mirroring, with error condition (%s)", sURLs.ErrorCond)
}
errDuringMirror = true
}
// Do not quit mirroring if we are in --watch or --active-active mode
if !mj.opts.activeActive && !mj.opts.isWatch {
cancel()
cancelInProgress = true
if !ignoreErr {
mirrorFailedOps.Inc()
errDuringMirror = true
// Quit mirroring if --watch and --active-active are not passed
if !mj.opts.activeActive && !mj.opts.isWatch {
cancel()
cancelInProgress = true
}
}
continue