Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 45 additions & 4 deletions test/e2e/e2e_leaderelection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Contributor

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".

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{
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Args in &defaultevictor.DefaultEvictorArgs follows #1472
Which may not be the proper args here

EvictLocalStoragePods: true, // [TODO] The values to set
},
},
},
Plugins: api.Plugins{
Filter: api.PluginSet{
Enabled: []string{
defaultevictor.PluginName,
},
},
Deschedule: api.PluginSet{
Enabled: []string{
podlifetime.PluginName,
},
},
},
},
},
}
}
Expand Down Expand Up @@ -124,10 +157,18 @@ func TestLeaderElection(t *testing.T) {
}
t.Logf("Removed kube-system/descheduler lease")

tc := struct {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use single tc here instead of the tests []struct in #1472
Not sure if it's better to use []struct, includes the cases of ns1 and ns2 then run
But I suppose ns1 and ns2 should belongs to the same test case

Copy link
Contributor

@ingvagabund ingvagabund Aug 15, 2024

Choose a reason for hiding this comment

The 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
Expand All @@ -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
Expand Down