-
Notifications
You must be signed in to change notification settings - Fork 684
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
feature(descheduler): add grace_period_seconds for DeschedulerPolicy #1538
base: master
Are you sure you want to change the base?
feature(descheduler): add grace_period_seconds for DeschedulerPolicy #1538
Conversation
Skipping CI for Draft Pull Request. |
7a7d780
to
84abd13
Compare
@googs1025 looks good in overall. Thank you. This is a good candidate for e2e testing. Would you please add an e2e test as well? So we can keep validating the functionality. |
sound great. maybe I can work this in weekend. :) |
I looked at the e2e test. Do you @ingvagabund have any good suggestions? I am currently planning to pick one of them for testing. For example: use the test/e2e/e2e_failedpods_test.go Policy for testing. Set GracePeriodSeconds. For example: set GracePeriodSeconds to 60 seconds, use wait.PollUntilContextTimeout to test before 60 seconds, the expected EvictedPodCount should be 0, and use wait.PollUntilContextTimeout again after 60 seconds. The expected EvictedPodCount should be actualEvictedPodCount. 🤔 |
The simplest test will do :) I would go with https://github.com/kubernetes-sigs/descheduler/blob/master/test/e2e/e2e_toomanyrestarts_test.go. Better to evict a pod that's still running. |
84abd13
to
ac99d2e
Compare
ac99d2e
to
6a93bd3
Compare
721d33b
to
d7725a4
Compare
@@ -197,6 +205,30 @@ func TestTooManyRestarts(t *testing.T) { | |||
deschedulerPodName = deschedulerPods[0].Name | |||
} | |||
|
|||
// Check if grace period is enabled and wait accordingly | |||
if tc.enableGracePeriod { |
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.
We add a wait here to ensure that no pod is evicted during the grace period.
baaed1c
to
1ff63a4
Compare
e35cc6b
to
e682927
Compare
/test pull-descheduler-test-e2e-k8s-master-1-31 |
@ingvagabund added |
@@ -517,7 +519,7 @@ func (pe *PodEvictor) EvictPod(ctx context.Context, pod *v1.Pod, opts EvictOptio | |||
return err | |||
} | |||
|
|||
ignore, err := pe.evictPod(ctx, pod) | |||
ignore, err := pe.evictPod(ctx, pod, pe.policyGroupVersion, pe.gracePeriodSeconds) |
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.
why is it being passed in as an argument, since it's already available on the PodEvictor receiver?
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.
done
func (pe *PodEvictor) evictPod(ctx context.Context, pod *v1.Pod, policyGroupVersion string, gracePeriodSeconds *int64) (bool, error) { | ||
deleteOptions := &metav1.DeleteOptions{} |
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.
func (pe *PodEvictor) evictPod(ctx context.Context, pod *v1.Pod, policyGroupVersion string, gracePeriodSeconds *int64) (bool, error) { | |
deleteOptions := &metav1.DeleteOptions{} | |
func (pe *PodEvictor) evictPod(ctx context.Context, pod *v1.Pod) (bool, error) { | |
deleteOptions := &metav1.DeleteOptions{ | |
GracePeriodSeconds: pe.gracePeriodSeconds, | |
} |
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.
Awkward..... The changes here were undone during rebase. thanks for this
65ac965
to
b2a8f66
Compare
/lgtm /assign @ingvagabund |
b2a8f66
to
77b17fb
Compare
New changes are detected. LGTM label has been removed. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/test pull-descheduler-test-e2e-k8s-master-1-31 |
77b17fb
to
9485934
Compare
/test pull-descheduler-test-e2e-k8s-master-1-30 |
/retest |
// The value zero indicates delete immediately. If this value is nil, the default grace period for the | ||
// specified type will be used. | ||
// Defaults to a per object value if not specified. zero means delete immediately. | ||
GracePeriodSeconds *int64 |
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.
Missing json:"gracePeriodSeconds,omitempty"
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.
Also worth extending https://github.com/kubernetes-sigs/descheduler?tab=readme-ov-file#example-policy with e.g. gracePeriodSeconds: 60
alongside already existing pluginConfig
arguments.
/kind feature
Fix #1537