reduce logging during permission denied errors (#18641)

log them if any only once
This commit is contained in:
Harshavardhana 2023-12-12 16:11:17 -08:00 committed by GitHub
parent 946b070744
commit d521c84d55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 10 deletions

View File

@ -121,13 +121,13 @@ func readBackgroundHealInfo(ctx context.Context, objAPI ObjectLayer) backgroundH
buf, err := readConfig(ctx, objAPI, backgroundHealInfoPath) buf, err := readConfig(ctx, objAPI, backgroundHealInfoPath)
if err != nil { if err != nil {
if !errors.Is(err, errConfigNotFound) { if !errors.Is(err, errConfigNotFound) {
logger.LogIf(ctx, err) logger.LogOnceIf(ctx, err, backgroundHealInfoPath)
} }
return backgroundHealInfo{} return backgroundHealInfo{}
} }
var info backgroundHealInfo var info backgroundHealInfo
if err = json.Unmarshal(buf, &info); err != nil { if err = json.Unmarshal(buf, &info); err != nil {
logger.LogIf(ctx, err) logger.LogOnceIf(ctx, err, backgroundHealInfoPath)
} }
return info return info
} }
@ -203,7 +203,7 @@ func runDataScanner(ctx context.Context, objAPI ObjectLayer) {
results := make(chan DataUsageInfo, 1) results := make(chan DataUsageInfo, 1)
go storeDataUsageInBackend(ctx, objAPI, results) go storeDataUsageInBackend(ctx, objAPI, results)
err := objAPI.NSScanner(ctx, results, uint32(cycleInfo.current), scanMode) err := objAPI.NSScanner(ctx, results, uint32(cycleInfo.current), scanMode)
logger.LogIf(ctx, err) logger.LogOnceIf(ctx, err, "ns-scanner")
res := map[string]string{"cycle": strconv.FormatUint(cycleInfo.current, 10)} res := map[string]string{"cycle": strconv.FormatUint(cycleInfo.current, 10)}
if err != nil { if err != nil {
res["error"] = err.Error() res["error"] = err.Error()
@ -223,7 +223,7 @@ func runDataScanner(ctx context.Context, objAPI ObjectLayer) {
binary.LittleEndian.PutUint64(tmp, cycleInfo.next) binary.LittleEndian.PutUint64(tmp, cycleInfo.next)
tmp, _ = cycleInfo.MarshalMsg(tmp) tmp, _ = cycleInfo.MarshalMsg(tmp)
err = saveConfig(ctx, objAPI, dataUsageBloomNamePath, tmp) err = saveConfig(ctx, objAPI, dataUsageBloomNamePath, tmp)
logger.LogIf(ctx, err) logger.LogOnceIf(ctx, err, dataUsageBloomNamePath)
} }
} }
} }
@ -729,7 +729,7 @@ func (f *folderScanner) scanFolder(ctx context.Context, folder cachedFolder, int
versionID: "", versionID: "",
}, madmin.HealItemObject) }, madmin.HealItemObject)
if !isErrObjectNotFound(err) && !isErrVersionNotFound(err) { if !isErrObjectNotFound(err) && !isErrVersionNotFound(err) {
logger.LogIf(ctx, err) logger.LogOnceIf(ctx, err, entry.name)
} }
foundObjs = foundObjs || err == nil foundObjs = foundObjs || err == nil
return return
@ -746,7 +746,7 @@ func (f *folderScanner) scanFolder(ctx context.Context, folder cachedFolder, int
}, madmin.HealItemObject) }, madmin.HealItemObject)
stopFn(int(ver.Size)) stopFn(int(ver.Size))
if !isErrObjectNotFound(err) && !isErrVersionNotFound(err) { if !isErrObjectNotFound(err) && !isErrVersionNotFound(err) {
logger.LogIf(ctx, err) logger.LogOnceIf(ctx, err, fiv.Name)
} }
if err == nil { if err == nil {
successVersions++ successVersions++
@ -1133,7 +1133,7 @@ func (i *scannerItem) applyActions(ctx context.Context, o ObjectLayer, oi Object
err := o.CheckAbandonedParts(ctx, i.bucket, i.objectPath(), madmin.HealOpts{Remove: healDeleteDangling}) err := o.CheckAbandonedParts(ctx, i.bucket, i.objectPath(), madmin.HealOpts{Remove: healDeleteDangling})
done() done()
if err != nil { if err != nil {
logger.LogIf(ctx, fmt.Errorf("unable to check object %s/%s for abandoned data: %w", i.bucket, i.objectPath(), err)) logger.LogOnceIf(ctx, fmt.Errorf("unable to check object %s/%s for abandoned data: %w", i.bucket, i.objectPath(), err), i.objectPath())
} }
} }
} }
@ -1199,7 +1199,7 @@ func applyExpiryOnTransitionedObject(ctx context.Context, objLayer ObjectLayer,
if isErrObjectNotFound(err) || isErrVersionNotFound(err) { if isErrObjectNotFound(err) || isErrVersionNotFound(err) {
return false return false
} }
logger.LogIf(ctx, err) logger.LogOnceIf(ctx, err, obj.Name)
return false return false
} }
// Notification already sent in *expireTransitionedObject*, just return 'true' here. // Notification already sent in *expireTransitionedObject*, just return 'true' here.

View File

@ -56,7 +56,7 @@ func storeDataUsageInBackend(ctx context.Context, objAPI ObjectLayer, dui <-chan
attempts = 1 attempts = 1
} }
if err = saveConfig(ctx, objAPI, dataUsageObjNamePath, dataUsageJSON); err != nil { if err = saveConfig(ctx, objAPI, dataUsageObjNamePath, dataUsageJSON); err != nil {
logger.LogIf(ctx, err) logger.LogOnceIf(ctx, err, dataUsageObjNamePath)
} }
attempts++ attempts++
} }

View File

@ -2275,6 +2275,7 @@ func (s *xlStorage) RenameData(ctx context.Context, srcVolume, srcPath string, f
errDiskNotFound, errDiskNotFound,
errUnformattedDisk, errUnformattedDisk,
errMaxVersionsExceeded, errMaxVersionsExceeded,
errFileAccessDenied,
} }
if err != nil && !IsErr(err, ignoredErrs...) && !contextCanceled(ctx) { if err != nil && !IsErr(err, ignoredErrs...) && !contextCanceled(ctx) {
// Only log these errors if context is not yet canceled. // Only log these errors if context is not yet canceled.
@ -2282,7 +2283,7 @@ func (s *xlStorage) RenameData(ctx context.Context, srcVolume, srcPath string, f
s.drivePath, s.drivePath,
srcVolume, srcPath, srcVolume, srcPath,
dstVolume, dstPath, dstVolume, dstPath,
err), "xl-storage-rename-data-"+srcVolume+"-"+dstVolume) err), "xl-storage-rename-data-"+dstVolume)
} }
if err == nil && s.globalSync { if err == nil && s.globalSync {
globalSync() globalSync()