chore(defaultevictor): add MatchExpressions compatibility to the namespaceselector#1853
Conversation
|
Welcome @Fankhauserli! |
|
Hi @Fankhauserli. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/ok-to-test |
|
/lgtm |
| }) | ||
|
|
||
| fakeClient := fake.NewClientset(node, nsProd, nsBackend, nsTest, podInProd, podInBackend, podInTest) | ||
| fakeClient := fake.NewSimpleClientset(node, nsProd, nsBackend, nsTest, podInProd, podInBackend, podInTest) |
There was a problem hiding this comment.
Is this intentional? The newly written tests use NewSimpleClientset.
|
|
||
| fakeClient := fake.NewClientset(node, nsProd, nsTest, podInProd, podInTest) | ||
| sharedInformerFactory := informers.NewSharedInformerFactory(fakeClient, 0) | ||
| getPodAssignedToNode, _ := podutil.BuildGetPodsAssignedToNodeFunc(sharedInformerFactory.Core().V1().Pods().Informer()) |
There was a problem hiding this comment.
Probably rare to fail here but still good practice to check the error
| testCases := []struct { | ||
| name string | ||
| args *DefaultEvictorArgs | ||
| results map[string]bool // pod name -> should pass PreEvictionFilter |
There was a problem hiding this comment.
What about to create a list of pointers to pods to pass and not pass to make the selection more explicit instead of constructing it at the end? To make the test easier to read.
| nsNoLabels.Labels = map[string]string{} | ||
|
|
||
| podInProd := test.BuildTestPod("pod-in-prod", 100, 100, node.Name, func(pod *v1.Pod) { | ||
| pod.Namespace = "ns-prod" |
There was a problem hiding this comment.
pod.Namespace = nsProd.Name to avoid duplicating the string literal. The same for other occurences.
| nsNoLabels := test.BuildTestNamespace("ns-nolabels") | ||
| nsNoLabels.Labels = map[string]string{} | ||
|
|
||
| podInProd := test.BuildTestPod("pod-in-prod", 100, 100, node.Name, func(pod *v1.Pod) { |
There was a problem hiding this comment.
s/podInProd/podInProdFrontend to make it explicit. The same for other occurences.
| defer cancel() | ||
| node := test.BuildTestNode("node1", 1000, 2000, 10, nil) | ||
|
|
||
| podProd := test.BuildTestPod("pod-prod", 100, 100, node.Name, func(pod *v1.Pod) { |
There was a problem hiding this comment.
ditto. s/podProd/podProdFrontend and other occurences
| testCases := []struct { | ||
| name string | ||
| args *DefaultEvictorArgs | ||
| results map[string]bool // pod name -> should pass Filter |
|
The first commit introduces a lot of test code that is then removed/updated in the second commit. Can you please either squash the commits or make the new tests part of a single commit? |
|
@Fankhauserli thank you for the code changes and welcome as a contributor |
|
/approve |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Description
We noticed that the new
NamespaceLabelSelectordoes not implement the MatchExpressions selector. This is vital for our workflow, as we need to use an exclusion label with aMatchExpression.Our target configuration looks something like this:
Currently, the descheduler only checks for MatchLabels:
This Pull Request updates the condition to account for MatchExpressions as well, and adds the corresponding tests to ensure the new behavior works as expected.
Checklist
Please ensure your pull request meets the following criteria before submitting
for review, these items will be used by reviewers to assess the quality and
completeness of your changes: