Add 'disk' tag to log output to enhance 'disk not found' errors (#6460)

This commit is contained in:
Harshavardhana 2018-09-13 21:42:50 -07:00 committed by kannappanr
parent 14fa0097b0
commit a63bc9254d
6 changed files with 15 additions and 3 deletions

View File

@ -138,7 +138,9 @@ func (b *bitrotReader) ReadChunk(offset int64, length int64) ([]byte, error) {
if b.buf == nil {
b.buf = make([]byte, b.endOffset-offset)
if _, err := b.disk.ReadFile(b.volume, b.filePath, offset, b.buf, b.verifier); err != nil {
logger.LogIf(context.Background(), err)
ctx := context.Background()
logger.GetReqInfo(ctx).AppendTags("disk", b.disk.String())
logger.LogIf(ctx, err)
return nil, err
}
}

View File

@ -28,6 +28,10 @@ import (
type badDisk struct{ StorageAPI }
func (a badDisk) String() string {
return "bad-disk"
}
func (a badDisk) AppendFile(volume string, path string, buf []byte) error {
return errFaultyDisk
}

View File

@ -117,6 +117,9 @@ func GetReqInfo(ctx context.Context) *ReqInfo {
if ok {
return r
}
r = &ReqInfo{}
SetReqInfo(ctx, r)
return r
}
return nil
}

View File

@ -29,7 +29,7 @@ var printEndpointError = func() func(Endpoint, error) {
printOnce := make(map[Endpoint]map[string]bool)
return func(endpoint Endpoint, err error) {
reqInfo := (&logger.ReqInfo{}).AppendTags("endpoint", endpoint.Host)
reqInfo := (&logger.ReqInfo{}).AppendTags("endpoint", endpoint.String())
ctx := logger.SetReqInfo(context.Background(), reqInfo)
m, ok := printOnce[endpoint]
if !ok {

View File

@ -305,6 +305,7 @@ func readXLMeta(ctx context.Context, disk StorageAPI, bucket string, object stri
xlMetaBuf, err := disk.ReadAll(bucket, path.Join(object, xlMetaJSONFile))
if err != nil {
if err != errFileNotFound {
logger.GetReqInfo(ctx).AppendTags("disk", disk.String())
logger.LogIf(ctx, err)
}
return xlMetaV1{}, err

View File

@ -78,7 +78,9 @@ func getDisksInfo(disks []StorageAPI) (disksInfo []DiskInfo, onlineDisks int, of
}
info, err := storageDisk.DiskInfo()
if err != nil {
logger.LogIf(context.Background(), err)
ctx := context.Background()
logger.GetReqInfo(ctx).AppendTags("disk", storageDisk.String())
logger.LogIf(ctx, err)
if IsErr(err, baseErrs...) {
offlineDisks++
continue