diff --git a/cmd/bitrot.go b/cmd/bitrot.go index d93441bb0..40e6839c5 100644 --- a/cmd/bitrot.go +++ b/cmd/bitrot.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 } } diff --git a/cmd/erasure-encode_test.go b/cmd/erasure-encode_test.go index 87cf935bc..d39be90d0 100644 --- a/cmd/erasure-encode_test.go +++ b/cmd/erasure-encode_test.go @@ -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 } diff --git a/cmd/logger/reqinfo.go b/cmd/logger/reqinfo.go index 616b295c2..ae932969e 100644 --- a/cmd/logger/reqinfo.go +++ b/cmd/logger/reqinfo.go @@ -117,6 +117,9 @@ func GetReqInfo(ctx context.Context) *ReqInfo { if ok { return r } + r = &ReqInfo{} + SetReqInfo(ctx, r) + return r } return nil } diff --git a/cmd/prepare-storage.go b/cmd/prepare-storage.go index 21016e7de..41fc8bffc 100644 --- a/cmd/prepare-storage.go +++ b/cmd/prepare-storage.go @@ -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 { diff --git a/cmd/xl-v1-utils.go b/cmd/xl-v1-utils.go index cdf50a2b7..be5efa084 100644 --- a/cmd/xl-v1-utils.go +++ b/cmd/xl-v1-utils.go @@ -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 diff --git a/cmd/xl-v1.go b/cmd/xl-v1.go index 09a302231..1d971d3cc 100644 --- a/cmd/xl-v1.go +++ b/cmd/xl-v1.go @@ -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