-
Notifications
You must be signed in to change notification settings - Fork 668
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
skip eviction when pod creation time is below minPodAge threshold setting #1475
Changes from 1 commit
2b8d996
ec7ad04
a8502e4
61b7b99
c7de3c4
9adea9f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ package v1alpha1 | |
import ( | ||
"context" | ||
"fmt" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please undone the new line removal? To keep this file unchanged. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 61b7b99 |
||
v1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/conversion" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -186,10 +186,10 @@ func New(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plug | |
}) | ||
} | ||
|
||
if defaultEvictorArgs.MinPodAge > 0 { | ||
if defaultEvictorArgs.MinPodAge != nil { | ||
ev.constraints = append(ev.constraints, func(pod *v1.Pod) error { | ||
if pod.Status.StartTime == nil || time.Since(pod.Status.StartTime.Time) < time.Duration(defaultEvictorArgs.MinPodAge)*time.Minute { | ||
return fmt.Errorf("pod age is not older than MinPodAge: %d minutes", defaultEvictorArgs.MinPodAge) | ||
if pod.Status.StartTime == nil || time.Since(pod.Status.StartTime.Time) < defaultEvictorArgs.MinPodAge.Duration { | ||
return fmt.Errorf("pod age is not older than MinPodAge: %d seconds", uint(defaultEvictorArgs.MinPodAge.Duration.Seconds())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 9adea9f |
||
} | ||
return nil | ||
}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ type testCase struct { | |
priorityThreshold *int32 | ||
nodeFit bool | ||
minReplicas uint | ||
minPodAge uint | ||
minPodAge *metav1.Duration | ||
result bool | ||
} | ||
|
||
|
@@ -329,6 +329,8 @@ func TestDefaultEvictorFilter(t *testing.T) { | |
lowPriority := int32(800) | ||
highPriority := int32(900) | ||
|
||
minPodAge := metav1.Duration{50 * time.Minute} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in c7de3c4 |
||
|
||
nodeTaintKey := "hardware" | ||
nodeTaintValue := "gpu" | ||
|
||
|
@@ -705,15 +707,15 @@ func TestDefaultEvictorFilter(t *testing.T) { | |
minReplicas: 2, | ||
result: true, | ||
}, { | ||
description: "minPodAge of 50, pod created 1 minute ago, no eviction", | ||
description: "minPodAge of 50, pod created 10 minutes ago, no eviction", | ||
pods: []*v1.Pod{ | ||
test.BuildTestPod("p1", 1, 1, n1.Name, func(pod *v1.Pod) { | ||
pod.ObjectMeta.OwnerReferences = test.GetNormalPodOwnerRefList() | ||
podStartTime := metav1.Now().Add(time.Minute * time.Duration(-1)) | ||
podStartTime := metav1.Now().Add(time.Minute * time.Duration(-10)) | ||
pod.Status.StartTime = &metav1.Time{Time: podStartTime} | ||
}), | ||
}, | ||
minPodAge: 50, | ||
minPodAge: &minPodAge, | ||
result: false, | ||
}, { | ||
description: "minPodAge of 50, pod created 60 minutes ago, evicts", | ||
|
@@ -724,8 +726,18 @@ func TestDefaultEvictorFilter(t *testing.T) { | |
pod.Status.StartTime = &metav1.Time{Time: podStartTime} | ||
}), | ||
}, | ||
minPodAge: 50, | ||
minPodAge: &minPodAge, | ||
result: true, | ||
}, { | ||
description: "nil minPodAge, pod created 60 minutes ago, evicts", | ||
pods: []*v1.Pod{ | ||
test.BuildTestPod("p1", 1, 1, n1.Name, func(pod *v1.Pod) { | ||
pod.ObjectMeta.OwnerReferences = test.GetNormalPodOwnerRefList() | ||
podStartTime := metav1.Now().Add(time.Minute * time.Duration(-60)) | ||
pod.Status.StartTime = &metav1.Time{Time: podStartTime} | ||
}), | ||
}, | ||
result: true, | ||
}, | ||
} | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
"in minutes" can be dropped
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 in a8502e4 ty!