mirror of
https://github.com/minio/minio.git
synced 2025-04-15 16:39:16 -04:00
fix: handle errors appropriately as they are wrapped (#10917)
This commit is contained in:
parent
08b24620c0
commit
73e308079a
@ -21,6 +21,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -371,6 +372,7 @@ func (r *metacacheReader) filter(o listPathOptions) (entries metaCacheEntriesSor
|
|||||||
func (er *erasureObjects) streamMetadataParts(ctx context.Context, o listPathOptions) (entries metaCacheEntriesSorted, err error) {
|
func (er *erasureObjects) streamMetadataParts(ctx context.Context, o listPathOptions) (entries metaCacheEntriesSorted, err error) {
|
||||||
retries := 0
|
retries := 0
|
||||||
rpc := globalNotificationSys.restClientFromHash(o.Bucket)
|
rpc := globalNotificationSys.restClientFromHash(o.Bucket)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
@ -423,6 +425,7 @@ func (er *erasureObjects) streamMetadataParts(ctx context.Context, o listPathOpt
|
|||||||
return entries, fmt.Errorf("reading first part metadata: %w", err)
|
return entries, fmt.Errorf("reading first part metadata: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if fi.Deleted {
|
if fi.Deleted {
|
||||||
return entries, errFileNotFound
|
return entries, errFileNotFound
|
||||||
}
|
}
|
||||||
@ -559,14 +562,24 @@ func (er *erasureObjects) listPath(ctx context.Context, o listPathOptions) (entr
|
|||||||
if debugPrint {
|
if debugPrint {
|
||||||
console.Printf("listPath with options: %#v\n", o)
|
console.Printf("listPath with options: %#v\n", o)
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if we have the listing stored.
|
// See if we have the listing stored.
|
||||||
if !o.Create && !o.singleObject {
|
if !o.Create && !o.singleObject {
|
||||||
entries, err := er.streamMetadataParts(ctx, o)
|
entries, err := er.streamMetadataParts(ctx, o)
|
||||||
switch err {
|
if IsErr(err, []error{
|
||||||
case nil, io.EOF, context.Canceled, context.DeadlineExceeded:
|
nil,
|
||||||
return entries, err
|
context.Canceled,
|
||||||
|
context.DeadlineExceeded,
|
||||||
|
}...) {
|
||||||
|
// Expected good errors we don't need to return error.
|
||||||
|
return entries, nil
|
||||||
}
|
}
|
||||||
logger.LogIf(ctx, err)
|
|
||||||
|
if !errors.Is(err, io.EOF) { // io.EOF is expected and should be returned but no need to log it.
|
||||||
|
// Log an return errors on unexpected errors.
|
||||||
|
logger.LogIf(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
return entries, err
|
return entries, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -587,7 +600,7 @@ func (er *erasureObjects) listPath(ctx context.Context, o listPathOptions) (entr
|
|||||||
if debugPrint {
|
if debugPrint {
|
||||||
console.Println("listPath returning:", entries.len(), "err:", err)
|
console.Println("listPath returning:", entries.len(), "err:", err)
|
||||||
}
|
}
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && !errors.Is(err, io.EOF) {
|
||||||
go func(err string) {
|
go func(err string) {
|
||||||
metaMu.Lock()
|
metaMu.Lock()
|
||||||
if meta.status != scanStateError {
|
if meta.status != scanStateError {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user