Skip to content

Commit

Permalink
Merge pull request #5521 from mohamedawnallah/logMutatingWebhookHandlers
Browse files Browse the repository at this point in the history
pkg/webhook: log mutating handlers in `OverridePolicy`, `ClusterPropagationPolicy`, and `MultiClusterService`
  • Loading branch information
karmada-bot committed Sep 12, 2024
2 parents 2ce29ea + df270fa commit 927dc33
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/webhook/clusterpropagationpolicy/mutating.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions pkg/webhook/multiclusterservice/mutating.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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()
Expand Down
1 change: 1 addition & 0 deletions pkg/webhook/overridepolicy/mutating.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 927dc33

Please sign in to comment.