do not log checksum mismatch error, client received the error (#16246)

This commit is contained in:
Harshavardhana 2022-12-14 01:57:40 -08:00 committed by GitHub
parent 0159b56717
commit c73ea27ed7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 4 deletions

View file

@ -22,6 +22,7 @@ import (
"io"
"sync"
"github.com/minio/minio/internal/hash"
"github.com/minio/minio/internal/logger"
)
@ -83,9 +84,16 @@ func (e *Erasure) Encode(ctx context.Context, src io.Reader, writers []io.Writer
for {
var blocks [][]byte
n, err := io.ReadFull(src, buf)
if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF {
logger.LogIf(ctx, err)
return 0, err
if err != nil {
if !IsErrIgnored(err, []error{
io.EOF,
io.ErrUnexpectedEOF,
}...) {
if !hash.IsChecksumMismatch(err) {
logger.LogIf(ctx, err)
}
return 0, err
}
}
eof := err == io.EOF || err == io.ErrUnexpectedEOF
if n == 0 && total != 0 {

View file

@ -17,7 +17,10 @@
package hash
import "fmt"
import (
"errors"
"fmt"
)
// SHA256Mismatch - when content sha256 does not match with what was sent from client.
type SHA256Mismatch struct {
@ -58,3 +61,9 @@ type ChecksumMismatch struct {
func (e ChecksumMismatch) Error() string {
return "Bad checksum: Want " + e.Want + " does not match calculated " + e.Got
}
// IsChecksumMismatch matches if 'err' is hash.ChecksumMismatch
func IsChecksumMismatch(err error) bool {
var herr ChecksumMismatch
return errors.As(err, &herr)
}