mirror of
https://github.com/minio/minio.git
synced 2025-01-12 15:33:22 -05:00
Revert proxying requests with precondition errors (#15180)
In a replicated setup, when an object is updated in one cluster but still waiting to be replicated to the other cluster, GET requests with if-match, and range headers will likely fail. It is better to proxy requests instead. Also, this commit avoids printing verbose logs about precondition & range errors.
This commit is contained in:
parent
767c1436d3
commit
b7c7e59dac
@ -297,6 +297,10 @@ func ErrorRespToObjectError(err error, params ...string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch minioErr.Code {
|
switch minioErr.Code {
|
||||||
|
case "PreconditionFailed":
|
||||||
|
err = PreConditionFailed{}
|
||||||
|
case "InvalidRange":
|
||||||
|
err = InvalidRange{}
|
||||||
case "BucketAlreadyOwnedByYou":
|
case "BucketAlreadyOwnedByYou":
|
||||||
err = BucketAlreadyOwnedByYou{}
|
err = BucketAlreadyOwnedByYou{}
|
||||||
case "BucketNotEmpty":
|
case "BucketNotEmpty":
|
||||||
|
@ -420,11 +420,6 @@ func (api objectAPIHandlers) getObjectHandler(ctx context.Context, objectAPI Obj
|
|||||||
|
|
||||||
gr, err := getObjectNInfo(ctx, bucket, object, rs, r.Header, readLock, opts)
|
gr, err := getObjectNInfo(ctx, bucket, object, rs, r.Header, readLock, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if isErrPreconditionFailed(err) {
|
|
||||||
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
reader *GetObjectReader
|
reader *GetObjectReader
|
||||||
proxy proxyResult
|
proxy proxyResult
|
||||||
@ -434,10 +429,13 @@ func (api objectAPIHandlers) getObjectHandler(ctx context.Context, objectAPI Obj
|
|||||||
if !proxytgts.Empty() {
|
if !proxytgts.Empty() {
|
||||||
// proxy to replication target if active-active replication is in place.
|
// proxy to replication target if active-active replication is in place.
|
||||||
reader, proxy, perr = proxyGetToReplicationTarget(ctx, bucket, object, rs, r.Header, opts, proxytgts)
|
reader, proxy, perr = proxyGetToReplicationTarget(ctx, bucket, object, rs, r.Header, opts, proxytgts)
|
||||||
if perr != nil && !isErrObjectNotFound(ErrorRespToObjectError(perr, bucket, object)) &&
|
if perr != nil {
|
||||||
!isErrVersionNotFound(ErrorRespToObjectError(perr, bucket, object)) {
|
proxyGetErr := ErrorRespToObjectError(perr, bucket, object)
|
||||||
|
if !isErrObjectNotFound(proxyGetErr) && !isErrVersionNotFound(proxyGetErr) &&
|
||||||
|
!isErrPreconditionFailed(proxyGetErr) && !isErrInvalidRange(proxyGetErr) {
|
||||||
logger.LogIf(ctx, fmt.Errorf("Replication proxy failed for %s/%s(%s) - %w", bucket, object, opts.VersionID, perr))
|
logger.LogIf(ctx, fmt.Errorf("Replication proxy failed for %s/%s(%s) - %w", bucket, object, opts.VersionID, perr))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if reader != nil && proxy.Proxy && perr == nil {
|
if reader != nil && proxy.Proxy && perr == nil {
|
||||||
gr = reader
|
gr = reader
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user