mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-18 04:54:54 +00:00
fix(apiserver): convert V().Error() to V().Info() for verbosity-aware logging
The go-logr/logr package ignores verbosity levels when using the Error
method. This means logger.V(1).Error() will always log regardless of
the verbosity setting, which contradicts the developer's intent.
This commit converts V(1).Error(err, "msg") to V(1).Info("msg", "err", err)
in the authorizeUnsafeDelete function to properly respect the verbosity
level.
This issue was identified in PR #136190 which adds a logcheck linter
rule to detect this pattern.
This commit is contained in:
@@ -415,7 +415,7 @@ func authorizeUnsafeDelete(ctx context.Context, attr admission.Attributes, authz
|
||||
decision, reason, err := authz.Authorize(ctx, record)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("error while checking permission for %q, %w", record.Verb, err)
|
||||
klog.FromContext(ctx).V(1).Error(err, "failed to authorize")
|
||||
klog.FromContext(ctx).V(1).Info("failed to authorize", "err", err)
|
||||
return admission.NewForbidden(attr, err)
|
||||
}
|
||||
if decision == authorizer.DecisionAllow {
|
||||
|
||||
Reference in New Issue
Block a user