pkg/webhook: log mutating webhook handlers
In this commit, we log the mutating handlers for `OverridePolicy`, `ClusterPropagationPolicy`, and `MultiClusterService`. Specifically, it logs information about the mutation of these resources, including the namespace, name, and the operation type from the admission request. Signed-off-by: Mohamed Awnallah <mohamedmohey2352@gmail.com>
This commit is contained in:
parent
32c2ef7aa4
commit
df270fab91
|
@ -23,6 +23,7 @@ import (
|
|||
|
||||
"github.com/google/uuid"
|
||||
admissionv1 "k8s.io/api/admission/v1"
|
||||
"k8s.io/klog/v2"
|
||||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
||||
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
|
||||
|
||||
|
@ -59,6 +60,7 @@ func (a *MutatingAdmission) Handle(_ context.Context, req admission.Request) adm
|
|||
if err != nil {
|
||||
return admission.Errored(http.StatusBadRequest, err)
|
||||
}
|
||||
klog.V(2).Infof("Mutating ClusterPropagationPolicy(%s/%s) for request: %s", req.Namespace, policy.Name, req.Operation)
|
||||
|
||||
// Set default spread constraints if both 'SpreadByField' and 'SpreadByLabel' not set.
|
||||
helper.SetDefaultSpreadConstraints(policy.Spec.Placement.SpreadConstraints)
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"k8s.io/klog/v2"
|
||||
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
|
||||
|
||||
networkingv1alpha1 "github.com/karmada-io/karmada/pkg/apis/networking/v1alpha1"
|
||||
|
@ -44,6 +45,7 @@ func (a *MutatingAdmission) Handle(_ context.Context, req admission.Request) adm
|
|||
if err != nil {
|
||||
return admission.Errored(http.StatusBadRequest, err)
|
||||
}
|
||||
klog.V(2).Infof("Mutating MultiClusterService(%s/%s) for request: %s", req.Namespace, mcs.Name, req.Operation)
|
||||
|
||||
if util.GetLabelValue(mcs.Labels, networkingv1alpha1.MultiClusterServicePermanentIDLabel) == "" {
|
||||
id := uuid.New().String()
|
||||
|
|
|
@ -43,6 +43,7 @@ func (a *MutatingAdmission) Handle(_ context.Context, req admission.Request) adm
|
|||
if err != nil {
|
||||
return admission.Errored(http.StatusBadRequest, err)
|
||||
}
|
||||
klog.V(2).Infof("Mutating OverridePolicy(%s/%s) for request: %s", req.Namespace, policy.Name, req.Operation)
|
||||
|
||||
// Set default namespace for all resource selector if not set.
|
||||
// We need to get the default namespace from the request because for kube-apiserver < v1.24,
|
||||
|
|
Loading…
Reference in New Issue