Repository: minio/minio (language: go)

Issue:
Spammy logs with "At least one of the pre-conditions you specified did not hold"
## NOTE
Hello,

I just upgraded from 2022-06-20T23-13-45Z to 2022-06-25T15:50:16Z.

Since then I have an important number of log lines looking like this:

```
API: GetObject
Time: Mon Jun 27 2022 08:42:27 GMT+0200 (Central European Summer Time)
DeploymentID: 3234941a-ebbb-4f7d-9133-3b56838f80cd
RequestID: 16FC6DABD7C24457
RemoteHost: 192.168.152.12
UserAgent: Mozilla/5.0 (Linux; Android 11; CPH2269 Build/RP1A.200720.011; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/94.0.4606.85 Mobile Safari/537.36
Error: At least one of the pre-conditions you specified did not hold (cmd.PreConditionFailed)

Backtrace: 
0: internal/logger/logger.go:278:logger.LogIf()
1: cmd/api-errors.go:2123:cmd.toAPIErrorCode()
2: cmd/api-errors.go:2148:cmd.toAPIError()
3: cmd/object-handlers.go:424:cmd.objectAPIHandlers.getObjectHandler()
4: cmd/object-handlers.go:604:cmd.objectAPIHandlers.GetObjectHandler()
5: net/http/server.go:2084:http.HandlerFunc.ServeHTTP()`
```

They weren't there before, but I don't see any impact on my workload yet. If there is no impact, then this should be a debug log and shouldn't clutter the logs of a production setup. If there is an impact then we face a regression since the last version.

## Expected Behavior
These log lines doesn't appear anymore.

## Current Behavior
The logs are cluttered with these lines.

## Possible Solution
Set this type of log as a debug log if this isn't the symptom of a regression, fix the regression otherwise.

## Steps to Reproduce (for bugs)
Upgrade from 2022-06-20T23-13-45Z to 2022-06-25T15:50:16Z.
Serve files to clients with Cache-Control header enabled.

## Regression
Regression since last version, possibly related to https://github.com/minio/minio/commit/1cfb03fb7431d3d530ed0703527f571b49779a5d

## Your Environment
Version used (`minio --version`): 2022-06-25T15:50:16Z



Discussion / hints:
Taking a look

Fix patch:
diff --git a/cmd/gateway-common.go b/cmd/gateway-common.go
index cb76dad6d1b3d..b61b6de088132 100644
--- a/cmd/gateway-common.go
+++ b/cmd/gateway-common.go
@@ -297,6 +297,10 @@ func ErrorRespToObjectError(err error, params ...string) error {
 	}
 
 	switch minioErr.Code {
+	case "PreconditionFailed":
+		err = PreConditionFailed{}
+	case "InvalidRange":
+		err = InvalidRange{}
 	case "BucketAlreadyOwnedByYou":
 		err = BucketAlreadyOwnedByYou{}
 	case "BucketNotEmpty":
diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go
index 88a449b6c047e..924ee724d1b7e 100644
--- a/cmd/object-handlers.go
+++ b/cmd/object-handlers.go
@@ -420,11 +420,6 @@ func (api objectAPIHandlers) getObjectHandler(ctx context.Context, objectAPI Obj
 
 	gr, err := getObjectNInfo(ctx, bucket, object, rs, r.Header, readLock, opts)
 	if err != nil {
-		if isErrPreconditionFailed(err) {
-			writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL)
-			return
-		}
-
 		var (
 			reader *GetObjectReader
 			proxy  proxyResult
@@ -434,9 +429,12 @@ func (api objectAPIHandlers) getObjectHandler(ctx context.Context, objectAPI Obj
 		if !proxytgts.Empty() {
 			// proxy to replication target if active-active replication is in place.
 			reader, proxy, perr = proxyGetToReplicationTarget(ctx, bucket, object, rs, r.Header, opts, proxytgts)
-			if perr != nil && !isErrObjectNotFound(ErrorRespToObjectError(perr, bucket, object)) &&
-				!isErrVersionNotFound(ErrorRespToObjectError(perr, bucket, object)) {
-				logger.LogIf(ctx, fmt.Errorf("Replication proxy failed for %s/%s(%s) - %w", bucket, object, opts.VersionID, perr))
+			if perr != nil {
+				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))
+				}
 			}
 			if reader != nil && proxy.Proxy && perr == nil {
 				gr = reader


Test patch: