-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(garcedelete webhook): refactor garcedelete webhook with podd… #146
Conversation
…eletion_controller
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #146 +/- ##
==========================================
- Coverage 63.54% 63.36% -0.19%
==========================================
Files 72 72
Lines 4704 4708 +4
==========================================
- Hits 2989 2983 -6
- Misses 1430 1438 +8
- Partials 285 287 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
if newPod.Labels[appsv1alpha1.PodDeletionIndicationLabelKey] == "true" { | ||
return nil | ||
} | ||
newPod.Labels[appsv1alpha1.PodDeletionIndicationLabelKey] = "true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you set the label value to a timestamp? It would be better to troubleshoot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The label value has been set to a timestamp.
if newPod.Labels == nil { | ||
newPod.Labels = map[string]string{} | ||
} | ||
if newPod.Labels[appsv1alpha1.PodDeletionIndicationLabelKey] == "true" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The label value would not always be true
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Row 71 has been fixed as
if _, ok := newPod.Labels[appsv1alpha1.PodDeletionIndicationLabelKey]; ok {return nil}
@@ -49,42 +49,44 @@ 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 { | |||
if !feature.DefaultFeatureGate.Enabled(features.GraceDeleteWebhook) || operation != admissionv1.Delete || !utils.ControlledByKusionStack(oldPod) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about changing the oldPod
in utils.ControlledByKusionStack(oldPod)
to newPod
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no newPod
for DELETE request, since the oldObject field is nil
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
…eletion_controller
1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):
2. What is the scope of this PR (e.g. component or file name):
pkg/webhook/server/generic/pod/gracedelete
3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):
The garcedelete webhook is refactored in this PR, to fix that The sts workload is not supported in last version.
In this PR, pod deletion requests are intercepted by the garcedelete webhook firstly, and then label pod to trigger poddeletion_controlelr reconcile.
4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):
5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:
6. Release note