1012 Commits
Author SHA1 Message Date
kubernetes-prow[bot]andGitHub ef090e93de Merge pull request #1915 from PKNaveen/code-cleanup-EvictionRequests
(Code-cleanup) removed EvictionRequests
2026-08-18 11:53:05 +00:00
PKNaveen 6fe697934e removed EvictionRequests 2026-08-11 11:19:34 +00:00
Amir Alavi ec736d7140 fix(e2e): harden test suite isolation, resource usage, and leader election timing
- Isolate TestLiveMigrationInBackground into dedicated e2e-livemigration namespace with t.Cleanup teardown.
- Switch VMI containerdisk image from fedora (1.2GB, 512MB RAM) to cirros-container-disk-demo (12MB, 128MB RAM), reducing Kind memory pressure by 75%.
- Filter pod list API calls with LabelSelector=kubevirt.io=virt-launcher to reduce API server serialization load.
- Override --descheduling-interval to 3s in startDeschedulerServer (e2e_leaderelection_test.go) so leader descheduler re-evaluates pod lifetime periodically.
- Exclude context cancellation/deadline from isClientRateLimiterError in e2e_test.go so context deadlines are not swallowed.
- Add t.Cleanup and IsAlreadyExists handling to prevent leftover resources from causing cascading failures.

Signed-off-by: Amir Alavi <amiralavi7@gmail.com>
2026-08-09 11:18:09 -04:00
Simone Tiraboschi 81fb28c18c fix: emit eviction metrics for background evictions that never get deleted
Pods evicted in background may stay in Succeeded/Failed phase forever
without being garbage-collected, so the metric was silently dropped.
Similarly, entries whose background eviction timed out in cleanCache
were expired without recording an outcome.

- UpdateFunc: emit "success"/"error" metric when a pod transitions to
  PodSucceeded/PodFailed respectively, matching the label convention
  used elsewhere in the file
- cleanCache: add onAssumedTimeout callback on evictionRequestsCache,
  wired in NewPodEvictor to emit "error" for entries that exceed the
  assumed-eviction timeout
- Add TestEvictionInBackgroundMetrics_PodCompleted and
  TestEvictionInBackgroundMetrics_AssumedTimeout to cover both paths

Signed-off-by: Simone Tiraboschi <stirabos@redhat.com>
2026-06-03 19:08:15 +02:00
Jan Chaloupka 66918dc553 fix(test/setupTestSandbox): wait until initial objects are propagated to informers 2026-05-18 16:46:24 +02:00
Linus FankhauserandGitHub 6b5f6b450c chore(defaultevictor): add matchlabels compatibility to the namespaceselector (#1853) 2026-05-18 16:45:53 +05:30
Simone Tiraboschi a7ac072c7d evictions: fix assumePod silently dropping success metric on informer race
When KubeVirt sets EvictionInProgressAnnotationKey before returning
TooManyRequests, the informer's UpdateFunc can call addPod
(evictionAssumed=false) before evictPod's assumePod call arrives.
assumePod found the entry already present and returned early, leaving
evictionAssumed=false. DeleteFunc then skipped the "success" metric.

Fix: if the existing entry has evictionAssumed=false (added by addPod),
upgrade it in place without double-counting the pod in the counters.

Adds TestEvictionInBackgroundMetrics_InformerRace to reproduce the race
deterministically.

Signed-off-by: Simone Tiraboschi <stirabos@redhat.com>
2026-05-14 17:23:18 +02:00
Simone Tiraboschi e56144c7a2 fix(descheduler): reset prometheus usage client at each extension point
Profile creation was moved outside the descheduling cycle in b214c147,
but reconcileInClusterSAToken() still runs only in runFnc(), after
newDescheduler() returns. This leaves the prometheus client nil when
LowNodeUtilization's New() runs, causing "prometheus client not
initialized" at startup.

Avoid failing at plugin creation time if the prometheus
client is not yet available. Instead, usageClientForMetrics() is now
called at the start of every extension point via a resetUsageClient()
helper, so each descheduling cycle picks up the latest client regardless
of when the SA token is reconciled or rotated.

Fixes: https://github.com/kubernetes-sigs/descheduler/issues/1840

Signed-off-by: Simone Tiraboschi <stirabos@redhat.com>
2026-04-29 11:36:32 +02:00
Simone Tiraboschi bc0f0354c6 evictions: fix missing observability for background evictions
Background evictions were completely invisible in metrics: the ignore=true
path caused EvictPod to return before incrementing any counter, leaving
operators with no signal that a background eviction had been triggered or
completed.

Add a "background" result label emitted at eviction request time and a
"success" label emitted from the informer DeleteFunc when the pod is
actually gone. The two labels together give a complete picture:
"background" is recorded at eviction request time and may not have a
matching "success" if the descheduler restarts before the pod is deleted,
while "success" confirms the eviction completed within the same lifecycle.

Signed-off-by: Simone Tiraboschi <stirabos@redhat.com>
2026-04-20 11:20:58 +02:00
sammedsingalkar09 212b706950 security: upgrade grpc and otel sdk dependencies
Bump gRPC and OpenTelemetry SDK/exporter dependencies to patched releases and refresh vendored modules to address reported vulnerabilities while keeping tracing resource schema versions consistent.

Made-with: Cursor
2026-04-18 13:12:03 +05:30
Kubernetes Prow RobotandGitHub 0fafc09fff Merge pull request #1844 from a7i/extend-podlifetime-transitions
Extend PodLifeTime with condition, exit code, owner kind, and transition time filters
2026-03-07 01:04:21 +05:30
Amir Alavi a4391ea73b Extract shared container state matching helpers into podutil
Move container waiting/terminated state checking from PodLifeTime and
RemovePodsHavingTooManyRestarts into podutil as separate exported helpers:
HasMatchingContainerWaitingState and HasMatchingContainerTerminatedState.
Each plugin composes only the helpers it needs.
2026-03-06 12:18:05 -05:00
Amir Alavi a845ed3b36 Extend PodLifeTime with condition, exit code, owner kind, and transition time filters 2026-03-06 12:17:07 -05:00
sammedsingalkar09 e76287fbbf update go dependencies 2026-03-06 11:24:00 +05:30
Jan Chaloupka cbdab93459 fix: resolve detected data races 2026-02-25 16:38:10 +01:00
Kubernetes Prow RobotandGitHub 0de5bad232 Merge pull request #1827 from a7i/k8s-1.35
[v0.35.0] bump to kubernetes 1.35 deps
2026-02-18 16:31:37 +05:30
Jan Chaloupka a868c8d129 chore: update the code based on golangci-lint report 2026-02-17 22:01:25 +01:00
Amir Alavi a206a88d86 [v0.35.0] bump to kubernetes 1.35 deps
Signed-off-by: Amir Alavi <amiralavi7@gmail.com>
2026-02-15 19:50:50 -05:00
Jan Chaloupka f4718bf928 refactor(prom client controllers): change the one letter receiver into ctrl 2026-02-05 15:54:49 +01:00
Jan Chaloupka f149f5a083 refactor: move prometheus client controller related code under a seperate file 2026-02-05 15:42:47 +01:00
Jan Chaloupka b214c14793 feat(pkg/descheduler): create profiles outside the descheduling cycle 2026-02-04 20:04:31 +01:00
Jan Chaloupka d262c7af44 refactor(TestPromClientControllerSync_EventHandler): be more verbose about the target expectations 2026-02-04 17:44:17 +01:00
Jan Chaloupka 4b5be0a772 feat(prometheus client reconciling): be more strict about clearing the previous connection
To avoid stalling connections that are not expected to be kept. E.g.
when an invalid secret is provided.
2026-02-04 17:16:44 +01:00
Jan Chaloupka 29e5a51cb5 refactor(newSecretBasedPromClientController): inline setupPrometheusProvider into newSecretBasedPromClientController 2026-02-04 17:16:15 +01:00
Jan Chaloupka a91a02cadc refactor(newSecretBasedPromClientController): move prometheus config validation under newSecretBasedPromClientController 2026-02-04 17:14:58 +01:00
Jan Chaloupka 964df4ce95 refactor(promClientController): split it into two prom client controllers 2026-02-04 16:59:13 +01:00
Jan Chaloupka c357bc3d28 test(TestReconcileInClusterSAToken): have prometheus client tests build an entire descheduler as well 2026-02-04 13:26:00 +01:00
Jan Chaloupka f8a4efd4f0 format(TestReconcileInClusterSAToken): indent the code by two tabs 2026-02-04 13:18:53 +01:00
Jan Chaloupka 0822f6f99a test(TestPromClientControllerSync_EventHandler): have prometheus client tests build an entire descheduler as well 2026-02-04 13:18:07 +01:00
Jan Chaloupka 4361c133e9 format(TestPromClientControllerSync_EventHandler): indent the code by two tabs 2026-02-04 13:11:20 +01:00
Jan Chaloupka 818675f73e refactor(TestPromClientControllerSync_EventHandler): get secret name and namespace from the implicitly generated secret object 2026-02-04 12:47:41 +01:00
Jan Chaloupka a8f618c3fd test(TestPromClientControllerSync_ClientCreation): have prometheus client tests build an entire descheduler as well 2026-02-04 12:41:31 +01:00
Jan Chaloupka 760bacab34 format(TestPromClientControllerSync_ClientCreation): indent the code by two tabs 2026-02-04 12:40:12 +01:00
Jan Chaloupka aa21eed809 refactor(setupPromClientControllerTest): inject context instead of creating a stop channel 2026-02-04 12:33:53 +01:00
Jan Chaloupka 807f580204 test(pkg/descheduler): TestPluginPrometheusClientAccess_Secret to test secret based token reconciliation
This test makes sure the secret is reconciled and available in plugins
while running the descheduler from its main entry point.
2026-02-04 11:31:18 +01:00
Jan Chaloupka 643179cdac feat(pkg/descheduler): setup prometheus client for the dry run mode descheduler as well
The secret is used for read-only operations so it can be safely wired.
2026-02-04 11:29:09 +01:00
Jan Chaloupka d1671034df refactor(pkg/descheduler): move the main descheduler run entry under a dedicated function 2026-02-03 23:31:29 +01:00
Jan Chaloupka f26ab740fe feat(pkg/descheduler): do not cancel the context when runDeschedulerLoop fails
When the descheduler is running in the dry mode the the kube client sandbox restoring may fail.
Which can be caused by timeouts when waiting for internal caches to sync.
The internal timeouts depend on the cluster size which changes in time.
No reason to cancel the context because of that.
2026-02-03 23:31:06 +01:00
Jan Chaloupka 0d05e5dd1f refactor(pkg/descheduler): dedicated function for setting token reconciliation 2026-02-03 23:31:01 +01:00
Jan Chaloupka e402adb9f1 refactor(pkg/descheduler): start factory informers and other descheduler parts during bootstrap
This will help with testing as the initDescheduler function under
descheduler_test.go is now much closer to the production invocation.
2026-02-03 21:33:28 +01:00
Jan Chaloupka 0c307cf7b9 refactor(pkg/descheduler): bootstrap a descheduler through a dedicated function 2026-02-03 21:26:16 +01:00
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
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
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