logging: Add subsystem to log API (#19002)

Create new code paths for multiple subsystems in the code. This will
make maintaing this easier later.

Also introduce bugLogIf() for errors that should not happen in the first
place.
This commit is contained in:
Anis Eleuch
2024-04-04 13:04:40 +01:00
committed by GitHub
parent 2228eb61cb
commit 95bf4a57b6
123 changed files with 972 additions and 786 deletions

View File

@@ -435,7 +435,7 @@ func (s *xlStorage) Healing() *healingTracker {
}
h := newHealingTracker()
_, err = h.UnmarshalMsg(b)
logger.LogIf(GlobalContext, err)
bugLogIf(GlobalContext, err)
return h
}
@@ -804,12 +804,12 @@ func (s *xlStorage) checkFormatJSON() (os.FileInfo, error) {
} else if osIsPermission(err) {
return nil, errDiskAccessDenied
}
logger.LogOnceIf(GlobalContext, err, "check-format-json") // log unexpected errors
storageLogOnceIf(GlobalContext, err, "check-format-json") // log unexpected errors
return nil, errCorruptedBackend
} else if osIsPermission(err) {
return nil, errDiskAccessDenied
}
logger.LogOnceIf(GlobalContext, err, "check-format-json") // log unexpected errors
storageLogOnceIf(GlobalContext, err, "check-format-json") // log unexpected errors
return nil, errCorruptedBackend
}
return fi, nil
@@ -855,19 +855,19 @@ func (s *xlStorage) GetDiskID() (string, error) {
} else if osIsPermission(err) {
return "", errDiskAccessDenied
}
logger.LogOnceIf(GlobalContext, err, "check-format-json") // log unexpected errors
storageLogOnceIf(GlobalContext, err, "check-format-json") // log unexpected errors
return "", errCorruptedBackend
} else if osIsPermission(err) {
return "", errDiskAccessDenied
}
logger.LogOnceIf(GlobalContext, err, "check-format-json") // log unexpected errors
storageLogOnceIf(GlobalContext, err, "check-format-json") // log unexpected errors
return "", errCorruptedBackend
}
format := &formatErasureV3{}
json := jsoniter.ConfigCompatibleWithStandardLibrary
if err = json.Unmarshal(b, &format); err != nil {
logger.LogOnceIf(GlobalContext, err, "check-format-json") // log unexpected errors
bugLogIf(GlobalContext, err) // log unexpected errors
return "", errCorruptedFormat
}
@@ -2439,7 +2439,7 @@ func (s *xlStorage) RenameData(ctx context.Context, srcVolume, srcPath string, f
}
if err != nil && !IsErr(err, ignoredErrs...) && !contextCanceled(ctx) {
// Only log these errors if context is not yet canceled.
logger.LogOnceIf(ctx, fmt.Errorf("drive:%s, srcVolume: %s, srcPath: %s, dstVolume: %s:, dstPath: %s - error %v",
storageLogOnceIf(ctx, fmt.Errorf("drive:%s, srcVolume: %s, srcPath: %s, dstVolume: %s:, dstPath: %s - error %v",
s.drivePath,
srcVolume, srcPath,
dstVolume, dstPath,
@@ -2538,12 +2538,12 @@ func (s *xlStorage) RenameData(ctx context.Context, srcVolume, srcPath string, f
xlMetaLegacy := &xlMetaV1Object{}
json := jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.Unmarshal(dstBuf, xlMetaLegacy); err != nil {
logger.LogOnceIf(ctx, err, "read-data-unmarshal-"+dstFilePath)
storageLogOnceIf(ctx, err, "read-data-unmarshal-"+dstFilePath)
// Data appears corrupt. Drop data.
} else {
xlMetaLegacy.DataDir = legacyDataDir
if err = xlMeta.AddLegacy(xlMetaLegacy); err != nil {
logger.LogOnceIf(ctx, err, "read-data-add-legacy-"+dstFilePath)
storageLogOnceIf(ctx, err, "read-data-add-legacy-"+dstFilePath)
}
legacyPreserved = true
}
@@ -2866,7 +2866,7 @@ func (s *xlStorage) VerifyFile(ctx context.Context, volume, path string, fi File
errFileVersionNotFound,
}...) {
logger.GetReqInfo(ctx).AppendTags("disk", s.String())
logger.LogOnceIf(ctx, err, partPath)
storageLogOnceIf(ctx, err, partPath)
}
return err
}