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

Avoid mirror fatalIf in multi-master #2998

Merged
merged 1 commit into from
Dec 9, 2019
Merged
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
38 changes: 32 additions & 6 deletions cmd/mirror-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,10 @@ func runMirror(srcURL, dstURL string, ctx *cli.Context, encKeyDB map[string][]pr
// Synchronize buckets using dirDifference function
for d := range dirDifference(srcClt, dstClt, srcURL, dstURL) {
if d.Error != nil {
if mj.multiMasterEnable {
errorIf(d.Error, "Failed to start mirroring.")
return true
}
mj.status.fatalIf(d.Error, "Failed to start mirroring.")
}
if d.Diff == differInSecond {
Expand Down Expand Up @@ -821,6 +825,10 @@ func runMirror(srcURL, dstURL string, ctx *cli.Context, encKeyDB map[string][]pr
// monitor mode will watch the source folders for changes,
// and queue them for copying.
if err := mj.watchURL(newSrcClt); err != nil {
if mj.multiMasterEnable {
errorIf(err, fmt.Sprintf("Failed to start monitoring."))
return true
}
mj.status.fatalIf(err, fmt.Sprintf("Failed to start monitoring."))
}
}
Expand All @@ -834,23 +842,41 @@ func runMirror(srcURL, dstURL string, ctx *cli.Context, encKeyDB map[string][]pr

// Create bucket if it doesn't exist at destination.
// ignore if already exists.
fatalIf(dstClt.MakeBucket(ctx.String("region"), true, withLock),
"Unable to create bucket at `"+dstURL+"`.")
if mj.multiMasterEnable {
err = dstClt.MakeBucket(ctx.String("region"), true, withLock)
errorIf(err, "Unable to create bucket at `"+dstURL+"`.")
if err != nil {
return true
}
} else {
mj.status.fatalIf(dstClt.MakeBucket(ctx.String("region"), true, withLock),
"Unable to create bucket at `"+dstURL+"`.")
}

// object lock configuration set on bucket
if mode != nil {
errorIf(dstClt.SetObjectLockConfig(mode, validity, unit),
"Unable to set object lock config in `"+dstURL+"`.")
err = dstClt.SetObjectLockConfig(mode, validity, unit)
errorIf(err, "Unable to set object lock config in `"+dstURL+"`.")
if err != nil && mj.multiMasterEnable {
return true
}
}

errorIf(copyBucketPolicies(srcClt, dstClt, isOverwrite),
"Unable to copy bucket policies to `"+dstClt.GetURL().String()+"`.")
err = copyBucketPolicies(srcClt, dstClt, isOverwrite)
errorIf(err, "Unable to copy bucket policies to `"+dstClt.GetURL().String()+"`.")
if err != nil && mj.multiMasterEnable {
return true
}
}

if !mirrorAllBuckets && mj.isWatch {
// monitor mode will watch the source folders for changes,
// and queue them for copying.
if err := mj.watchURL(srcClt); err != nil {
if mj.multiMasterEnable {
errorIf(err, fmt.Sprintf("Failed to start monitoring."))
return true
}
mj.status.fatalIf(err, fmt.Sprintf("Failed to start monitoring."))
}
}
Expand Down