Commit Graph

445 Commits

Author SHA1 Message Date
Adrian Moisey
ae25979790 Use a dedicated delete channel in HPA test
This is an attempt to fix a flake
2025-10-02 21:22:10 +02:00
Omer Aplatony
7af3377900 Add desired_replicas histogram metric to HPA controller
Signed-off-by: Omer Aplatony <omerap12@gmail.com>
2025-09-27 09:30:03 +00:00
Omer Aplatony
a8a21aaf85 Add hpa object count metric (#134140)
* Add hpa object count metrics

Signed-off-by: Omer Aplatony <omerap12@gmail.com>

* change name to num_horizontal_pod_autoscalers

Signed-off-by: Omer Aplatony <omerap12@gmail.com>

* remove log line

Signed-off-by: Omer Aplatony <omerap12@gmail.com>

---------

Signed-off-by: Omer Aplatony <omerap12@gmail.com>
2025-09-22 06:10:19 -07:00
Kubernetes Prow Robot
69e92c6827 Merge pull request #134022 from aditigupta96/cleanup-waitfornamedcachesync
refactor(controller): Use context-aware WaitForNamedCacheSync in resourcequota and HPA tests
2025-09-16 17:18:16 -07:00
Aditi Gupta
af231d2153 Replace WaitForNamedCacheSync with WaitForNamedCacheSyncWithContext in pkg/controller/ 2025-09-16 14:51:34 -07:00
Aditi Gupta
1ce12710ec refactor(controller): Use context-aware WaitForNamedCacheSync in resourcequota and HPA tests 2025-09-12 12:37:54 -07:00
Omer Aplatony
fbd33bd6b3 hpa: prevent integer overflow in external metrics sum
Signed-off-by: Omer Aplatony <omerap12@gmail.com>
2025-09-04 08:36:53 +00:00
Kubernetes Prow Robot
1bcfd5cee7 Merge pull request #133741 from kincoy/hpa-cleanup-redundant-casts
cleanup: remove redundant type conversions in podautoscaler
2025-09-01 04:35:20 -07:00
Kubernetes Prow Robot
5c107f08e9 Merge pull request #133708 from ingvagabund/podautoscaler-dont-print-panic
fix(controller/podautoscaler): do not print panic when .status.lastScaleTime is not set
2025-09-01 04:35:13 -07:00
kincoy
12a784b46b cleanup: remove redundant type conversions in podautoscaler
Signed-off-by: kincoy <kincoyao@gmail.com>
2025-08-28 14:28:57 +08:00
Kubernetes Prow Robot
5742171781 Merge pull request #133415 from AadiDev005/optimize-calculate-pod-requests
HPA: optimize calculatePodRequests for specific container lookups
2025-08-27 17:18:34 -07:00
Kubernetes Prow Robot
1c778ab972 Merge pull request #132503 from LoganGoogle/remove-redundant-code
Remove redundant MilliValue call in GetRawMetric for podautoscaler
2025-08-27 14:53:58 -07:00
Omer Aplatony
b9a8dffa51 Fix replicaCount calculation exceeding max int32 (#126979)
* Fix replicaCount calculation exceeding max int32

Signed-off-by: Omer Aplatony <omerap12@gmail.com>

* Add test for scaling up with overflow

Signed-off-by: Omer Aplatony <omerap12@gmail.com>

---------

Signed-off-by: Omer Aplatony <omerap12@gmail.com>
2025-08-27 14:53:15 -07:00
Jan Chaloupka
83da6f1a87 fix(controller/podautoscaler): do not print panic when .status.lastScaleTime is not set 2025-08-26 14:18:54 +02:00
aditya
bb6a0ea6b2 HPA: optimize calculatePodRequests for specific container lookups
- Add early exit when specific container is found in calculatePodRequestsFromContainers
- Add error handling for non-existent containers following existing patterns
- Maintain all existing functionality for pod-level resources and feature gates
- Include comprehensive function documentation

The optimization eliminates unnecessary container iterations when HPA targets
specific containers, providing significant performance improvements for pods
with many containers while preserving full backward compatibility
2025-08-20 19:13:00 +05:30
Luiz Oliveira
7fbf63a23f HPA support for pod-level resource specifications (#132430)
* HPA support for pod-level resource specifications

* Add e2e tests for HPA support for pod-level resource specifications
2025-07-29 09:02:26 -07:00
googs1025
b50d508176 bugfix(hpa): introduce buildQuantity helper for consistent resource quantity creation
Signed-off-by: googs1025 <googs1025@gmail.com>
2025-06-25 08:23:53 +08:00
Logan Zhai
a352bf8815 Remove redundant MilliValue call in GetRawMetric for podautoscaler,
which has no functional impact.
2025-06-24 14:06:21 +00:00
aumpatel
db2555628c Fix: HPA suppresses FailedRescale event on successful conflict retry
This change modifies the HPA controller to use retry.RetryOnConflict when updating a scale subresource. This prevents the controller from emitting a FailedRescale event on transient API conflicts if a subsequent retry succeeds. If the retry is successful, a SuccessfulRescale event is emitted. If all retries are exhausted and the conflict persists, the original FailedRescale event is emitted. This reduces event noise caused by race conditions where the scale subresource is updated by another process.
2025-06-12 07:35:07 -04:00
Kubernetes Prow Robot
fa10ea63a6 Merge pull request #127050 from omerap12/podautoscaler-ExternalPerpodMetricReplicas-intmax
HPA: Fix int overflow in GetExternalPerPodMetricReplicas
2025-05-09 13:37:14 -07:00
Omer Aplatony
af1d60f30b Add hpa reviewers
Signed-off-by: Omer Aplatony <omerap12@gmail.com>
2025-05-07 18:16:15 +00:00
Omer Aplatony
0acc7bd4dc HPA: Fix int overflow in GetExternalPerPodMetricReplicas
Signed-off-by: Omer Aplatony <omerap12@gmail.com>
2025-05-07 16:26:27 +00:00
Jean-Marc François
2dd9eda47f Add configurable tolerance logic. 2025-03-21 18:48:37 -04:00
mchtech
381ccf0f4c Fix empty describedObject in hpa status (#124555)
* fix empty DescribedObject in hpa MetricStatus when object target type is AverageValue

Signed-off-by: mchtech <michu_an@126.com>

* add test

Signed-off-by: mchtech <michu_an@126.com>

---------

Signed-off-by: mchtech <michu_an@126.com>
2025-03-18 09:33:56 -07:00
Kubernetes Prow Robot
586f0fad5c Merge pull request #125046 from tklauser/min-max-builtins
Use Go 1.21 min/max builtins
2025-01-30 07:33:23 -08:00
Adrian Moisey
42a5e5f425 Pass context down to wait.PollUntilContextTimeout 2025-01-07 16:25:55 +02:00
Adrian Moisey
6168143386 Remove use of deprecated functions
Removes use of deprecated functions in k8s.io/utils/pointer and k8s.io/apimachinery/pkg/util/sets
2024-12-31 15:11:38 +02:00
Kubernetes Prow Robot
77749c21f6 Merge pull request #127193 from DP19/ignore-unready-pods-hpa-containermetrics
allow ContainerResource calculations to continue with missing metrics like Resource calculations
2024-12-13 15:18:25 +01:00
Patrick Ohly
8a908e0c0b remove import doc comments
The "// import <path>" comment has been superseded by Go modules.
We don't have to remove them, but doing so has some advantages:

- They are used inconsistently, which is confusing.
- We can then also remove the (currently broken) hack/update-vanity-imports.sh.
- Last but not least, it would be a first step towards avoiding the k8s.io domain.

This commit was generated with
   sed -i -e 's;^package \(.*\) // import.*;package \1;' $(git grep -l '^package.*// import' | grep -v 'vendor/')

Everything was included, except for
   package labels // import k8s.io/kubernetes/pkg/util/labels
because that package is marked as "read-only".
2024-12-02 16:59:34 +01:00
Tobias Klauser
b01b016668 Use Go 1.21 min/max builtins
The `min` and `max` builtins are available since Go 1.21[^1]. The
top-level go.mod file is specifying Go 1.22, so the builtins can be
used.

[^1]: https://go.dev/doc/go1.21#language
2024-10-31 11:17:23 +01:00
David Pait
f97abdbee0 allow ContainerResource calculations to continue with missing metrics like Resource calculations 2024-10-06 11:27:21 -04:00
Matthieu MOREL
f777addb05 fix: use ErrorContains(t, err instead of Contains(t, err.Error()
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-09-26 22:22:20 +02:00
Abhishek Kr Srivastav
95860cff1c Fix Go vet errors for master golang
Co-authored-by: Rajalakshmi-Girish <rajalakshmi.girish1@ibm.com>
Co-authored-by: Abhishek Kr Srivastav <Abhishek.kr.srivastav@ibm.com>
2024-09-20 12:36:38 +05:30
Joe Betz
2595aa1309 generate 2024-09-03 14:26:26 -04:00
Matthieu MOREL
be59afc102 fix: enable testifylint on pkg/controller
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-07-12 06:18:34 +00:00
Kubernetes Prow Robot
2d4514e169 Merge pull request #125802 from mmorel-35/testifylint/len+empty
fix: enable empty and len rules from testifylint on pkg and staging package
2024-07-11 23:12:06 -07:00
Kubernetes Prow Robot
27c6c30905 Merge pull request #124607 from gjtempleton/HPA-Reviewers-Addition
HPA - Add gjtempleton to reviewers
2024-07-10 07:08:50 -07:00
Matthieu MOREL
f014b754fb fix: enable empty and len rules from testifylint on pkg package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

Co-authored-by: Patrick Ohly <patrick.ohly@intel.com>
2024-07-06 23:15:43 +00:00
SataQiu
4bd3baece3 kube-controller-manager: remove the deprecated horizontal-pod-autoscaler-upscale-delay and horizontal-pod-autoscaler-downscale-delay flags 2024-05-19 17:49:23 +08:00
Alvaro Aleman
6d0ac8c561 Use the generic/typed workqueue throughout
This change makes us use the generic workqueue throughout the project in
order to improve type safety and readability of the code.
2024-05-04 14:33:12 -04:00
Guy Templeton
7d540272b8 HPA - Add gjtempleton to reviewers 2024-04-29 09:29:49 +01:00
Claudiu Belu
2be8baeaef unittests: Skip failing Windows tests
Some of the unit tests are currently failing on Windows.

Skip them for now, and remove the skips later, once the underlying issues
have been resolved.
2024-04-25 14:24:16 +00:00
Kubernetes Prow Robot
2ec63e0d28 Merge pull request #123482 from sanposhiho/hpa-containerresource-graduation
graduate HPAContainerMetrics to stable
2024-03-06 17:37:36 -08:00
Mengjiao Liu
b584b87a94 kube-controller-manager: readjust log verbosity
- Increase the global level for broadcaster's logging to 3 so that users can ignore event messages by lowering the logging level. It reduces information noise.
- Making sure the context is properly injected into the broadcaster, this will allow the -v flag value to be used also in that broadcaster, rather than the above global value.
- test: use cancellation from ktesting
- golangci-hints: checked error return value
2024-02-26 14:51:56 +08:00
Kensei Nakada
07e0a80216 graduate HPAContainerMetrics to stable 2024-02-25 00:58:00 +00:00
Kubernetes Prow Robot
99bf6a674c Merge pull request #121039 from josselin-c/master
hpa: always update status metrics when updating the replica count
2023-10-28 19:35:01 +02:00
Kubernetes Prow Robot
2b16f7b6bb Merge pull request #120001 from qingwave/hpa-sidecar
HPA: calculate sidecar container resource in pod autoscaler
2023-10-23 18:39:31 +02:00
Josselin Costanzi
3c4512c6cc hpa: always update status metrics when updating the replica count
Have hpa always update both the metrics and replica count. This fix an
edge case behavior bug where the metrics would not be updated if a
custom metrics was unavailable.
2023-10-06 21:34:09 +00:00
Lukasz Stankiewicz
1b489963c8 Add nil checks for hpa object target type values 2023-10-05 17:15:51 -07:00
qingwave
7f805dc935 fix test name 2023-08-19 03:31:34 +00:00