-
Notifications
You must be signed in to change notification settings - Fork 687
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
[WIP] [TestLeaderElection] e2e: build a descheduler image and run the descheduler as a pod #1497
base: master
Are you sure you want to change the base?
Changes from 1 commit
8be31c7
c3767b2
5230bea
09faa13
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 |
---|---|---|
|
@@ -35,13 +35,46 @@ import ( | |
"sigs.k8s.io/descheduler/cmd/descheduler/app/options" | ||
"sigs.k8s.io/descheduler/pkg/api" | ||
"sigs.k8s.io/descheduler/pkg/descheduler" | ||
"sigs.k8s.io/descheduler/pkg/framework/plugins/defaultevictor" | ||
"sigs.k8s.io/descheduler/pkg/framework/plugins/podlifetime" | ||
) | ||
|
||
// Should use something like "sigs.k8s.io/descheduler/pkg/framework/plugins/removepodshavingtoomanyrestarts" | ||
func leaderElectionPolicy(targetNamespace string) *api.DeschedulerPolicy { | ||
func PodLifeTimePolicy(targetNamespace string, maxPodLifeTimeSeconds *uint) *api.DeschedulerPolicy { | ||
return &api.DeschedulerPolicy{ | ||
Profiles: []api.DeschedulerProfile{ | ||
{}, | ||
{ | ||
Name: "PodLifeTimeProfile", | ||
PluginConfigs: []api.PluginConfig{ | ||
{ | ||
Name: podlifetime.PluginName, | ||
Args: &podlifetime.PodLifeTimeArgs{ | ||
MaxPodLifeTimeSeconds: maxPodLifeTimeSeconds, // [TODO] The values to set | ||
Namespaces: &api.Namespaces{ | ||
Include: []string{targetNamespace}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
Name: defaultevictor.PluginName, | ||
Args: &defaultevictor.DefaultEvictorArgs{ | ||
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. Args in &defaultevictor.DefaultEvictorArgs follows #1472 |
||
EvictLocalStoragePods: true, // [TODO] The values to set | ||
}, | ||
}, | ||
}, | ||
Plugins: api.Plugins{ | ||
Filter: api.PluginSet{ | ||
Enabled: []string{ | ||
defaultevictor.PluginName, | ||
}, | ||
}, | ||
Deschedule: api.PluginSet{ | ||
Enabled: []string{ | ||
podlifetime.PluginName, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
@@ -124,10 +157,18 @@ func TestLeaderElection(t *testing.T) { | |
} | ||
t.Logf("Removed kube-system/descheduler lease") | ||
|
||
tc := struct { | ||
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. use single tc here instead of the tests []struct in #1472 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's currently only a single test to be run. With two descheduler pods run in the same namespace (kube-system). |
||
name string | ||
policy *api.DeschedulerPolicy | ||
}{ | ||
name: "leaderelection", | ||
policy: PodLifeTimePolicy(ns1, utilptr.To[uint](5)), | ||
} | ||
|
||
t.Log("starting deschedulers") | ||
|
||
go func() { | ||
err := descheduler.Run(ctx, s1) | ||
err := descheduler.RunDeschedulerStrategies(ctx, s1, tc.policy, "v1") | ||
if err != nil { | ||
t.Errorf("unable to start descheduler: %v", err) | ||
return | ||
|
@@ -137,7 +178,7 @@ func TestLeaderElection(t *testing.T) { | |
time.Sleep(1 * time.Second) | ||
|
||
go func() { | ||
err := descheduler.Run(ctx, s2) | ||
err := descheduler.RunDeschedulerStrategies(ctx, s2, tc.policy, "v1") | ||
if err != nil { | ||
t.Errorf("unable to start descheduler: %v", err) | ||
return | ||
|
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.
yes, in this case it would be
"sigs.k8s.io/descheduler/pkg/framework/plugins/podlifetime"
.