Commit Graph
2262 Commits
Author SHA1 Message Date
Jan Chaloupka a71c2ab331 refactor(pkg/descheduler): single ctx with cancel with the whole RunDeschedulerStrategies function for consistency 2026-02-03 21:15:13 +01:00
Kubernetes Prow RobotandGitHub ffd05ff9c1 Merge pull request #1818 from ingvagabund/prom-client-testing
tests: Prom client testing
2026-02-02 19:04:28 +05:30
Kubernetes Prow RobotandGitHub a60ab7b5ed Merge pull request #1786 from W1seKappa/add-namespace-label-selector
Add namespace label selector
2026-02-02 18:24:29 +05:30
Danila Bobkov 4361eefaf2 add namespaceLabelSelector
Signed-off-by: Danila Bobkov <danila.bobkov@flant.com>
2026-02-02 15:22:11 +03:00
Jan Chaloupka 5a53f16526 test(promClientController): unit test the implementation
Currently, there's a single prometheus client reconciler for both in
cluster and secret based strategies. The in cluster reconciling is run in
sync with each descheduling cycle. An in file token either changes or it
does not. If changed a new prometheus client is created. The secret
based reconciling is run async and watches for secret object changes. If a
secret changes a new client is created. The internal state of the
reconciler keeps previous connection data for clearing and checks.

The current reconciler implementation lacks mutually exclusive access.
So data races are possible. The prometheus configuration validation is
performed during every sync. The future refactorings is expected to move
the validation to the creation phase of the reconciler.

The extra unit testing is expected to cover the following scenarios:
- in cluster:
  - in file token is unchanged: no-op
  - in file token is changed: client is created or fails to be created
- secret:
  - no secret is not found: no client creation, internal state cleared
  - secret is found: if token changed a new client created, otherwise
    no-op
- prometheus config validation
- prometheus client injection

Any error during new prom client creation should be followed by closing
the previous connection and reseting the internal state. Yet, the error
handling is not that strict currently. So the current extra unit testing
keeps the incomplete testing cases as they are.

Other use of the tests is to make sure every time a new prometheus
client is created a descheduling cycle injects a new profile with the
updated prometheus clients. So the future refactoring does not introduce
a regression.
2026-02-01 18:13:18 +01:00
Jan Chaloupka 12b1ddfb52 refactor(pkg/descheduler): move prometheus client specific code under a dedicated promClientController
The underlying implementation is the same. Only moving the code under a
separate controller that can be unit test independently of the
descheduler type implementation.
2026-02-01 12:42:27 +01:00
Kubernetes Prow RobotandGitHub 0b4fd3544c Merge pull request #1816 from ingvagabund/prometheus-client-update-test
test(pkg/descheduler): test a prometheus client update propagates to a plugin profile handle
2026-01-26 03:01:08 +05:30
Jan Chaloupka fe2fb603f4 test(pkg/descheduler): test a prometheus client update propagates to a plugin profile handle 2026-01-25 22:00:28 +01:00
Kubernetes Prow RobotandGitHub a500ff9c64 Merge pull request #1814 from ingvagabund/refactorings
fix(kubeClientSandbox): do not wait for pods in the fake indexers if they are already deleted
2026-01-24 19:48:13 +05:30
Jan Chaloupka 263db33052 fix(kubeClientSandbox): do not wait for pods in the fake indexers if they are already deleted 2026-01-24 14:49:38 +01:00
Jan Chaloupka 45dc5a20d3 test(kubeClientSandbox): more unit tests 2026-01-24 14:47:17 +01:00
Jan Chaloupka f520856095 refactor(kubeClientSandbox): move the code under a separate file 2026-01-24 14:47:10 +01:00
Jan Chaloupka e53b3d5dce refactor(pkg/descheduler): drop unsed clientset parameter from descheduler.runProfiles 2026-01-23 22:27:59 +01:00
Kubernetes Prow RobotandGitHub 72d61286eb Merge pull request #1812 from ingvagabund/register-fake-factory-only-once
refactor(pkg/descheduler): create fake shared informer factory only once
2026-01-24 02:43:28 +05:30
Jan Chaloupka 770ec5affa refactor(pkg/descheduler): create fake shared informer factory only once 2026-01-23 21:34:09 +01:00
Kubernetes Prow RobotandGitHub 38d99dd0c3 Merge pull request #1813 from ingvagabund/refactorings
refactor(pkg/descheduler): more handlers and dropping unused code
2026-01-23 21:27:30 +05:30
Jan Chaloupka 8f5a83279e refactor(pkg/descheduler): drop unused fakeEvictedPods variables in the unit tests 2026-01-23 15:31:57 +01:00
Jan Chaloupka 4daa7e2fbf refactor(pkg/descheduler): move prometheus setup under a helper
Prometheus is not used anywhere in the tests so there's no need to setup
it there.
2026-01-23 15:31:57 +01:00
Jan Chaloupka 433f0dbb8c refactor(pkg/descheduler): define a helper for newKubeClientSandbox with the default list of resources 2026-01-23 15:31:51 +01:00
Kubernetes Prow RobotandGitHub cc96a3ee7a Merge pull request #1811 from ingvagabund/kube-client-sandbox
refactor(pkg/operator): replace informerResource with a kubeClientSandbox
2026-01-22 19:59:28 +05:30
Jan Chaloupka ff580a0eff refactor(kubeClientSandbox): keep a cache of evicted pods and allow to reset it at the end of each descheduling cycle 2026-01-22 14:49:47 +01:00
Jan Chaloupka 4af097a806 refactor(pkg/operator): create a helper for registering indexer in the dry run mode 2026-01-22 14:44:41 +01:00
Jan Chaloupka b3f0184af8 refactor(kubeClientSandbox): helpers for creating a node selector and node selector indexer 2026-01-22 14:44:32 +01:00
Jan Chaloupka 881ead3ed2 refactor(kubeClientSandbox): set the create pods reactor in buildSandbox 2026-01-22 14:44:14 +01:00
Jan Chaloupka fc6d0d1132 refactor(pkg/operator): replace informerResource with a kubeClientSandbox 2026-01-22 14:41:48 +01:00
Kubernetes Prow RobotandGitHub 85b1d97dda Merge pull request #1810 from ingvagabund/refactorings
chore(pkg/descheduler): make TestPodEvictorReset table driven
2026-01-20 19:08:49 +05:30
Jan Chaloupka b6aadc1643 chore(pkg/descheduler): make TestPodEvictorReset table driven 2026-01-20 12:51:58 +01:00
Kubernetes Prow RobotandGitHub c4ec31684f Merge pull request #1802 from ingvagabund/global-node-selector-as-indexer
feat: register a node indexer for the global node selector instead of listing nodes with the selector
2026-01-12 15:08:13 +05:30
Kubernetes Prow RobotandGitHub 7d2c31cd39 Merge pull request #1808 from ingvagabund/profile-instance-id
feat(profile): inject a plugin instance ID to each built plugin
2026-01-09 15:33:43 +05:30
Jan Chaloupka cf9edca33c feat(profile): inject a plugin instance ID to each built plugin 2026-01-06 12:26:35 +01:00
Kubernetes Prow RobotandGitHub f164943257 Merge pull request #1807 from ingvagabund/docs
doc(Design Decisions FAQ): Why doesn't the framework provide helpers for registering and retrieving indexers for plugins
2026-01-05 21:20:39 +05:30
Jan Chaloupka 1fe9e2c345 doc(Design Decisions FAQ): Why doesn't the framework provide helpers for registering and retrieving indexers for plugins 2026-01-05 16:10:39 +01:00
Kubernetes Prow RobotandGitHub 16ccff8ed8 Merge pull request #1806 from ingvagabund/profile-refactoring
refactor(pkg/framework/profile): dedup unit test code
2026-01-05 15:12:37 +05:30
Jan Chaloupka 38f0f15787 chore: make gen 2026-01-04 20:23:13 +01:00
Jan Chaloupka 52f2aea444 refactor(pkg/framework/profile): add registerDefaultEvictor helper function 2026-01-04 19:43:47 +01:00
Jan Chaloupka f3c63011cc refactor(pkg/framework/profile): add fake plugin registration helpers 2026-01-04 19:43:29 +01:00
Jan Chaloupka 47b939dd86 refactor(pkg/framework/profile): build a profile through a shared function to reduce code duplication 2026-01-04 19:42:30 +01:00
Kubernetes Prow RobotandGitHub 89c88f483b Merge pull request #1800 from ingvagabund/readnodes-unit-test
fix(TestReadyNodesWithNodeSelector): make sure nodeLister.List always returns a non-empty list so the lister is always tested
2025-12-26 20:48:31 +05:30
Kubernetes Prow RobotandGitHub d558fa3a5b Merge pull request #1804 from ingvagabund/refactorings
refactor(plugins): simplify the way pods are created
2025-12-21 14:38:30 -08:00
Jan Chaloupka 7ef3673d4c refactor: inline single-statement apply functions in BuildTestPod calls 2025-12-21 21:41:59 +01:00
Jan Chaloupka 988e0b8868 refactor: replace pod.Spec.Volumes with test.SetHostPathEmptyDirVolumeSource in plugin tests 2025-12-21 21:36:24 +01:00
Jan Chaloupka fc8ae3b4e8 refactor: replace pod.Spec.Priority with test.SetPodPriority in plugin tests 2025-12-21 21:36:05 +01:00
Kubernetes Prow RobotandGitHub 6d7fedc982 Merge pull request #1803 from ingvagabund/refactor-defaultevictir-test
refactor(TestDefaultEvictor): de-dup code and use helpers
2025-12-20 06:54:31 -08:00
Jan Chaloupka 769ded35f1 make fmt 2025-12-20 15:24:37 +01:00
Jan Chaloupka 3283635149 refactor(defaultevictor_test): move newProtectedStorageClassesConfig to package level
Move the newProtectedStorageClassesConfig helper function from local scope
to package level so it can be reused by both TestDefaultEvictorFilter and
Test_protectedPVCStorageClasses, eliminating code duplication.
2025-12-20 15:17:06 +01:00
Jan Chaloupka 994ce3e2f7 refactor(TestDefaultEvictor): add setPodPVCVolumeWithFooClaimName helper function 2025-12-20 14:36:10 +01:00
Jan Chaloupka 90e4115b78 refactor(TestDefaultEvictor): add setPodLocalStorage helper function 2025-12-20 14:29:19 +01:00
Jan Chaloupka 8913d79d14 refactor(TestDefaultEvictor): replace mirror pod annotation assignments with test.SetMirrorPodAnnotation 2025-12-20 14:28:08 +01:00
Jan Chaloupka 9a5d7e8286 refactor(TestDefaultEvictor): replace system critical priority assignments with test.SetPodPriority 2025-12-20 14:27:18 +01:00
Jan Chaloupka 674e463bc2 refactor(TestDefaultEvictor): replace manual owner reference assignments with test utilities 2025-12-20 14:25:58 +01:00