add context for mirror failures (#3464)

This commit is contained in:
Harshavardhana
2020-10-21 13:42:18 -07:00
committed by GitHub
parent 440f6dccbc
commit 91c9364f3c
6 changed files with 41 additions and 15 deletions
+2 -2
View File
@@ -209,8 +209,8 @@ func mustGetHostConfig(alias string) *aliasConfigV10 {
}
var (
hostKeys = regexp.MustCompile("^(https?://)(.*?):(.*?)@(.*?)$")
hostKeyTokens = regexp.MustCompile("^(https?://)(.*?):(.*?):(.*?)@(.*?)$")
hostKeys = regexp.MustCompile("^(https?://)(.*?):(.*)@(.*?)$")
hostKeyTokens = regexp.MustCompile("^(https?://)(.*?):(.*?):(.*)@(.*?)$")
)
// parse url usually obtained from env.
+17 -2
View File
@@ -36,9 +36,16 @@ func TestParseEnvURLStr(t *testing.T) {
port: "9000",
},
{
hostURL: "https://minio:minio123@localhost:9000",
hostURL: "https://minio:minio123@@localhost:9000",
accessKey: "minio",
secretKey: "minio123",
secretKey: "minio123@",
hostname: "localhost",
port: "9000",
},
{
hostURL: "https://minio:minio@123@@localhost:9000",
accessKey: "minio",
secretKey: "minio@123@",
hostname: "localhost",
port: "9000",
},
@@ -57,6 +64,14 @@ func TestParseEnvURLStr(t *testing.T) {
hostname: "localhost",
port: "9000",
},
{
hostURL: "https://minio:minio@123:token@@localhost:9000",
accessKey: "minio",
secretKey: "minio@123",
sessionToken: "token@",
hostname: "localhost",
port: "9000",
},
{
hostURL: "https://minio@localhost:9000",
accessKey: "minio",
+8 -7
View File
@@ -33,13 +33,14 @@ import (
type differType int
const (
differInNone differType = iota // does not differ
differInSize // differs in size
differInMetadata // differs in metadata
differInType // differs in type, exfile/directory
differInFirst // only in source (FIRST)
differInSecond // only in target (SECOND)
differInAASourceMTime // differs in active-active source modtime
differInUnknown differType = iota
differInNone // does not differ
differInSize // differs in size
differInMetadata // differs in metadata
differInType // differs in type, exfile/directory
differInFirst // only in source (FIRST)
differInSecond // only in target (SECOND)
differInAASourceMTime // differs in active-active source modtime
)
func (d differType) String() string {
+6 -1
View File
@@ -384,7 +384,12 @@ func (mj *mirrorJob) monitorMirrorStatus() (errDuringMirror bool) {
fmt.Sprintf("Failed to remove `%s`.", sURLs.TargetContent.URL.String()))
errDuringMirror = true
default:
errorIf(sURLs.Error.Trace(), "Failed to perform mirroring.")
if sURLs.ErrorCond == differInUnknown {
errorIf(sURLs.Error.Trace(), "Failed to perform mirroring")
} else {
errorIf(sURLs.Error.Trace(),
"Failed to perform mirroring, with error condition (%s)", sURLs.ErrorCond)
}
errDuringMirror = true
}
if mj.opts.activeActive {
+7 -3
View File
@@ -130,7 +130,7 @@ func deltaSourceTarget(ctx context.Context, sourceURL, targetURL string, opts mi
for diffMsg := range objectDifference(ctx, sourceClnt, targetClnt, sourceURL, targetURL, opts.isMetadata) {
if diffMsg.Error != nil {
// Send all errors through the channel
URLsCh <- URLs{Error: diffMsg.Error}
URLsCh <- URLs{Error: diffMsg.Error, ErrorCond: differInUnknown}
continue
}
@@ -154,7 +154,10 @@ func deltaSourceTarget(ctx context.Context, sourceURL, targetURL string, opts mi
case differInSize, differInMetadata, differInAASourceMTime:
if !opts.isOverwrite && !opts.isFake && !opts.activeActive {
// Size or time or etag differs but --overwrite not set.
URLsCh <- URLs{Error: errOverWriteNotAllowed(diffMsg.SecondURL)}
URLsCh <- URLs{
Error: errOverWriteNotAllowed(diffMsg.SecondURL),
ErrorCond: diffMsg.Diff,
}
continue
}
@@ -191,7 +194,8 @@ func deltaSourceTarget(ctx context.Context, sourceURL, targetURL string, opts mi
}
default:
URLsCh <- URLs{
Error: errUnrecognizedDiffType(diffMsg.Diff).Trace(diffMsg.FirstURL, diffMsg.SecondURL),
Error: errUnrecognizedDiffType(diffMsg.Diff).Trace(diffMsg.FirstURL, diffMsg.SecondURL),
ErrorCond: diffMsg.Diff,
}
}
}
+1
View File
@@ -32,6 +32,7 @@ type URLs struct {
DisableMultipart bool
encKeyDB map[string][]prefixSSEPair
Error *probe.Error `json:"-"`
ErrorCond differType `json:"-"`
}
// WithError sets the error and returns object