Skip to content

Commit

Permalink
style(gracedelete): optimize klog and annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
cyh-ant committed Dec 22, 2023
1 parent 9b92a79 commit 84c09d7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/webhook/server/generic/pod/gracedelete/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/types"
"k8s.io/klog"
"k8s.io/klog/v2"
"kusionstack.io/operating/apis/apps/v1alpha1"
"kusionstack.io/operating/pkg/controllers/poddeletion"
"kusionstack.io/operating/pkg/controllers/utils/podopslifecycle"
Expand All @@ -47,6 +47,8 @@ func (gd *GraceDelete) Name() string {
}

func (gd *GraceDelete) Validating(ctx context.Context, c client.Client, oldPod, newPod *corev1.Pod, operation admissionv1.Operation) error {
// GraceDeleteWebhook FeatureGate defaults to false
// Add '--feature-gates=GraceDeleteWebhook=true' to container args, to enable gracedelete webhook
if !feature.DefaultFeatureGate.Enabled(features.GraceDeleteWebhook) || operation != admissionv1.Delete {
return nil
}
Expand All @@ -58,7 +60,7 @@ func (gd *GraceDelete) Validating(ctx context.Context, c client.Client, oldPod,
return err
}

Check warning on line 61 in pkg/webhook/server/generic/pod/gracedelete/webhook.go

View check run for this annotation

Codecov / codecov/patch

pkg/webhook/server/generic/pod/gracedelete/webhook.go#L59-L61

Added lines #L59 - L61 were not covered by tests

klog.Info("pod is deleted")
klog.V(2).Info("pod is deleted")
return nil
}
if !utils.ControlledByKusionStack(pod) {
Expand Down

0 comments on commit 84c09d7

Please sign in to comment.