diff --git a/pkg/webhooks/policy/handlers.go b/pkg/webhooks/policy/handlers.go index 79f058598a..4e8dfeeb75 100644 --- a/pkg/webhooks/policy/handlers.go +++ b/pkg/webhooks/policy/handlers.go @@ -37,7 +37,7 @@ func (h *handlers) Validate(logger logr.Logger, request *admissionv1.AdmissionRe warnings, err := policyvalidate.Validate(policy, h.client, false, h.openApiManager) if err != nil { logger.Error(err, "policy validation errors") - return admissionutils.Response(err) + return admissionutils.Response(err, warnings...) } return admissionutils.Response(err, warnings...) } diff --git a/pkg/webhooks/resource/handlers.go b/pkg/webhooks/resource/handlers.go index 09481ff471..b84b25908f 100644 --- a/pkg/webhooks/resource/handlers.go +++ b/pkg/webhooks/resource/handlers.go @@ -134,13 +134,13 @@ func (h *handlers) Validate(logger logr.Logger, request *admissionv1.AdmissionRe ok, msg, warnings := vh.HandleValidation(h.metricsConfig, request, policies, policyContext, namespaceLabels, startTime) if !ok { logger.Info("admission request denied") - return admissionutils.Response(errors.New(msg)) + return admissionutils.Response(errors.New(msg), warnings...) } defer h.handleDelete(logger, request) go h.createUpdateRequests(logger, request, policyContext, generatePolicies, mutatePolicies, startTime) - return admissionutils.Response(nil, warnings...) + return admissionutils.ResponseSuccess(warnings...) } func (h *handlers) Mutate(logger logr.Logger, request *admissionv1.AdmissionRequest, failurePolicy string, startTime time.Time) *admissionv1.AdmissionResponse {