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

master
Harshavardhana 6 years ago committed by kannappanr
parent 14fa0097b0
commit a63bc9254d
  1. 4
      cmd/bitrot.go
  2. 4
      cmd/erasure-encode_test.go
  3. 3
      cmd/logger/reqinfo.go
  4. 2
      cmd/prepare-storage.go
  5. 1
      cmd/xl-v1-utils.go
  6. 4
      cmd/xl-v1.go

@ -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
}
}

@ -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
}

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

@ -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 {

@ -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

@ -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

Loading…
Cancel
Save