diff --git a/pkg/webhook/admission/http.go b/pkg/webhook/admission/http.go index 052f803161..c332833cc7 100644 --- a/pkg/webhook/admission/http.go +++ b/pkg/webhook/admission/http.go @@ -129,15 +129,13 @@ func (wh *Webhook) writeAdmissionResponse(w io.Writer, ar v1.AdmissionReview) { if err != nil { wh.log.Error(err, "unable to encode the response") wh.writeResponse(w, Errored(http.StatusInternalServerError, err)) - } else { - res := ar.Response - if log := wh.log; log.V(1).Enabled() { - if res.Result != nil { - log = log.WithValues("code", res.Result.Code, "reason", res.Result.Reason) - } - log.V(1).Info("wrote response", "UID", res.UID, "allowed", res.Allowed) - } } + + log := wh.log.V(1) + if result := ar.Response.Result; result != nil { + log = log.WithValues("code", result.Code, "reason", result.Reason) + } + log.V(1).Info("wrote response", "UID", ar.Response.UID, "allowed", ar.Response.Allowed) } // unversionedAdmissionReview is used to decode both v1 and v1beta1 AdmissionReview types. diff --git a/pkg/webhook/authentication/http.go b/pkg/webhook/authentication/http.go index 5c3472dfb6..77ad520190 100644 --- a/pkg/webhook/authentication/http.go +++ b/pkg/webhook/authentication/http.go @@ -136,10 +136,7 @@ func (wh *Webhook) writeTokenResponse(w io.Writer, ar authenticationv1.TokenRevi wh.log.Error(err, "unable to encode the response") wh.writeResponse(w, Errored(err)) } - res := ar - if log := wh.log; log.V(1).Enabled() { - log.V(1).Info("wrote response", "UID", res.UID, "authenticated", res.Status.Authenticated) - } + log.V(1).Info("wrote response", "UID", ar.UID, "authenticated", ar.Status.Authenticated) return } diff --git a/pkg/webhook/authorization/http.go b/pkg/webhook/authorization/http.go index c60366d2ea..12cf0e4f1f 100644 --- a/pkg/webhook/authorization/http.go +++ b/pkg/webhook/authorization/http.go @@ -117,11 +117,7 @@ func (wh *Webhook) writeSubjectAccessReviewResponse(w io.Writer, ar authorizatio wh.log.Error(err, "unable to encode the response") wh.writeResponse(w, Errored(err)) } - res := ar - if log := wh.log; log.V(1).Enabled() { - log.V(1).Info("wrote response", "UID", res.UID, "authorized", res.Status.Allowed) - } - return + log.V(1).Info("wrote response", "UID", ar.UID, "authorized", ar.Status.Allowed) } func (wh *Webhook) decodeRequestBody(body []byte) (unversionedSubjectAccessReview, *schema.GroupVersionKind, error) {