kubernetes-sigs / descheduler

Descheduler for Kubernetes
https://sigs.k8s.io/descheduler
Apache License 2.0
4.47k stars 668 forks source link

use pod informers for listing pods in removepodsviolatingtopologyspreadconstraint and removepodsviolatinginterpodantiaffinity #1163

Closed a7i closed 1 year ago

a7i commented 1 year ago

follow up to #1033 and apply the same in removepodsviolatingtopologyspreadconstraint

a7i commented 1 year ago

With informers, the returned pods are not in order so the assertion is failing. Any suggestions @knelasevero @ingvagabund ?

e.g. one of the tests is expecting this order:

expectedEvictedPods:  []string{"pod-5", "pod-6", "pod-7", "pod-8"},
damemi commented 1 year ago

With informers, the returned pods are not in order so the assertion is failing. Any suggestions @knelasevero @ingvagabund ?

e.g. one of the tests is expecting this order:

expectedEvictedPods:  []string{"pod-5", "pod-6", "pod-7", "pod-8"},

I haven't looked at the test, but is there anything semantically different about evicting those different pods? If it's just an ordering issue then you can sort or update the output

ingvagabund commented 1 year ago

/test all

ingvagabund commented 1 year ago

/retest-required

ingvagabund commented 1 year ago
topologyspreadconstraint_test.go:1220: Expected pods [pod-5 pod-6 pod-7 pod-8] to be evicted but [pod-8 pod-5 pod-6 pod-7] were not evicted. Actual pods evicted: [pod-1 pod-2 pod-3 pod-10 pod-11]

The test is probably broken. expectedEvictedCount is 5 but the list claims it needs only 4 items. We should probably randomize the order in which the pods are appended into objs var that is passed into fake.NewSimpleClientset in cases where the order does not matter. At the same time I recall we needed some tests to actually evict a specific list of pods so we can validate the code picks the right pods for eviction.

a7i commented 1 year ago
topologyspreadconstraint_test.go:1220: Expected pods [pod-5 pod-6 pod-7 pod-8] to be evicted but [pod-8 pod-5 pod-6 pod-7] were not evicted. Actual pods evicted: [pod-1 pod-2 pod-3 pod-10 pod-11]

The test is probably broken. expectedEvictedCount is 5 but the list claims it needs only 4 items. We should probably randomize the order in which the pods are appended into objs var that is passed into fake.NewSimpleClientset in cases where the order does not matter. At the same time I recall we needed some tests to actually evict a specific list of pods so we can validate the code picks the right pods for eviction.

Thanks @ingvagabund . The test only checks that expected is included in the evicted list, so having only 4 was passing before.

Yes, there are ~3 tests that are expecting a particular order. I can perhaps change them to evicted count per node/topology.

a7i commented 1 year ago

fyi - it used to be sorted, but then it changed: https://github.com/kubernetes/kubernetes/pull/75730

"noone should assume the fact that keys are sorted."

a7i commented 1 year ago

/label tide/merge-method-squash

ingvagabund commented 1 year ago

As long as the strategy works deterministically this is fine. /approve

k8s-ci-robot commented 1 year ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ingvagabund

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/kubernetes-sigs/descheduler/blob/master/OWNERS)~~ [ingvagabund] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
JaneLiuL commented 1 year ago

/lgtm