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
Filter pods by namespaces #338
Filter pods by namespaces #338
Conversation
1875a45
to
c5c8e76
Compare
/hold |
@seanmalloy I diverged a bit from the proposal renaming
|
https://travis-ci.org/github/kubernetes-sigs/descheduler/builds/707654262 going green as well |
We need to have |
/test pull-descheduler-test-e2e-k8s-master |
@ingvagabund: The specified target(s) for
Use In response to this:
Instructions 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/test-infra repository. |
Maybe a close/reopen will pull in the new test |
@damemi: Closed this PR. In response to this:
Instructions 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/test-infra repository. |
/reopen |
@damemi: Reopened this PR. In response to this:
Instructions 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/test-infra repository. |
Opened #340 to try and fix the e2e |
/retest |
) | ||
|
||
type Options struct { | ||
filter func(pod *v1.Pod) bool |
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.
Maybe better to make filter
a list of filter funcs, so that we can easily add more filters to descheduler without changing other funcs in pod util.
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.
You can always create function which will call all filter functions:
func(pod *v1.Pod) bool {
return filter1(pod) && ... filtern(pod)
}
and pass into WithFilter
.
c5c8e76
to
238a2ec
Compare
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.
My only real comment is that I think it should be clear that you can only set either Include or Exclude, rather than implicitly preferring one over the other
@@ -67,7 +67,7 @@ func TestListPodsOnANode(t *testing.T) { | |||
} | |||
return true, nil, fmt.Errorf("Failed to list: %v", list) | |||
}) | |||
pods, _ := ListPodsOnANode(context.TODO(), fakeClient, testCase.node, nil) | |||
pods, _ := ListPodsOnANode(context.TODO(), fakeClient, testCase.node) |
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.
+1 nice, we can get rid of these nil
s
!nodeutil.PodFitsCurrentNode(pod, node) && | ||
nodeutil.PodFitsAnyNode(pod, nodes) | ||
}), | ||
podutil.WithNamespaces(strategy.Params.Namespaces.Include), |
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.
Ah, I see now how the strategies can easily control whether they implement the include/exclude. Cool!
238a2ec
to
6628814
Compare
/retest |
57aaf97
to
2306f0c
Compare
/retest |
|
||
includePodNames := getPodNames(podList.Items) | ||
// validate all pod were deleted | ||
if len(intersectStrings(initialPodNames, includePodNames)) > 0 { |
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.
you could consider using sets.String
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.
As long as the slices are not too long, the naive implementation is fine.
test/e2e/e2e_test.go
Outdated
} | ||
} | ||
t.Logf("All %v pods are terminating", intersectStrings(initialPodNames, includePodNames)) | ||
return true, nil |
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.
don't think you need this, you have a return at the end of the function
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.
Removed
t.Logf("Waiting until %v pods get deleted", intersectStrings(initialPodNames, includePodNames)) | ||
// check if there's at least one pod not in Terminating state | ||
for _, pod := range podList.Items { | ||
if pod.DeletionTimestamp == nil { |
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.
This is including the newly created pods, so I think you just want to iterate over initialPods
? The errors in CI are failing against a pod that's not in your intersect list: https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_descheduler/338/pull-descheduler-test-e2e-k8s-master-1-16/1285935763120197633#1:build-log.txt%3A272
e2e_test.go:301: Waiting until [test-rc-podlifetime-9wqm7 test-rc-podlifetime-fvqt2 test-rc-podlifetime-hprj9 test-rc-podlifetime-q59m7 test-rc-podlifetime-vrdmk] pods get deleted
e2e_test.go:305: Pod test-rc-podlifetime-8lh7l not in terminating state
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.
I split it into two tests, each one running the strategy over separate namespace.
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.
ah good idea
6ec235f
to
69cf370
Compare
@ingvagabund: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions 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/test-infra repository. I understand the commands that are listed here. |
69cf370
to
9cb7a95
Compare
2fd939a
to
42db316
Compare
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.
/approve
thanks @ingvagabund this looks good to me
@seanmalloy wdyt?
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: damemi, 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:
Approvers can indicate their approval by writing |
/kind feature |
/lgtm |
…ds-by-namespaces Filter pods by namespaces
Fixes: #251
E2e for the exclude namespaces part are deleting all pods from all namespaces but
default
which are passing IsEvictable. It can be tricky when the test is run over a cluster with pods that are not supposed to be evicted during the test. Though, I don't see any other way how to do it now. On the other hand, running the descheduler is always destructive so it needs to be run under certain assumptions/conditions.With introduction of included namespaces one can configure the same strategy with with different conditions for eviction. E.g. evict pods in namespace N1 that are older than 1h but in namespace N2 only pods older than 2h.
The following strategies are subject to namespace filtering now:
Note: the policy config has backward incompatible changes for which we need to bump the version to v1alpha2
TODO:
Built on top of #343