TestStatefulSetScaleDownRespectsMinReadySeconds and
TestStatefulSetOnDeleteStrategyIgnoresMinReadySeconds are testing
.spec.minReadySeconds. This resulted in tests spinning sufficiently long
to reach the desired value. In both cases it was set to 30s.
This change modifies scaleUpStatefulSetControl allowing to inject
fakeClock which allows faster time changes, thus speeding the tests.
Signed-off-by: Maciej Szulik <soltysh@gmail.com>
* Fix format-string argument order in object metric error messages
The error format strings in GetObjectMetricReplicas and
GetObjectPerPodMetricReplicas had the arguments in the wrong order,
causing objectRef.Kind to be printed where the error should appear
and vice versa.
Signed-off-by: Mikhail Fedosin <mfedosin@redhat.com>
* Use %w for error wrapping in fmt.Errorf calls in podautoscaler
Replace %v with %w for error arguments in fmt.Errorf throughout the
HPA controller, replica calculator, and metrics client. This enables
proper error wrapping so that callers can use errors.Is and errors.As
to inspect underlying errors.
Signed-off-by: Mikhail Fedosin <mfedosin@redhat.com>
---------
Signed-off-by: Mikhail Fedosin <mfedosin@redhat.com>
The endpoint-mappings.yaml file specifies which components use which
metrics. The case some, but not all core components (kube-controller-manager
and kube-scheduler in this case) sharing the same metrics was not
supported. This gets fixed by not returning early once the first file path
matches.
Not all metrics in pkg/controller/resourceclaim/metrics are shared. To make the
sharing clearer and fit into the file-path based component support in
endpoint-mappings.yaml, the shared metric gets moved to a new
pkg/resourceclaim/metrics package.
Both kube-controller-manager and kube-scheduler create ResourceClaims. Using
the same metric (sub-system: "dynamic_resource_allocation", name:
"resourceclaim_creates_total") in both components simplifies aggregation across
the entire cluster.
Accessing svc.Spec.IPFamilies[0] without a bounds check panics when a
service reaches the controller with an empty IPFamilies field. This can
happen via watch events: the apiserver's defaultOnRead decorator populates
IPFamilies on GET/LIST but not on watch (cachingObject wrapping bypasses
the type assertion).
Restore the inference logic removed in #130101: fall back to ClusterIP
for headful services and pod IP for headless services.
Signed-off-by: Rahul <rahulbabu95@gmail.com>
- squash isFailed and isSucceeeded under single isTerminalPhase
- remove dropParentName in favor of getParentNameAndOrdinal
Signed-off-by: Maciej Szulik <soltysh@gmail.com>
Previously, creating or updating an HPA always went through
AddRateLimited, delaying reconciliation by the full resync period
(default 15s). This causes a noticeable lag between applying an HPA
and seeing it take effect, and grows worse with longer resync
intervals (e.g. 60s).
Switch enqueueHPA from queue.AddRateLimited to queue.Add so that
newly created HPAs are processed immediately. In updateHPA, compare
the Generation field (gated behind the HPAGeneration feature) to
distinguish spec changes from status-only updates: spec changes
trigger immediate reconciliation via queue.Add, while status-only
changes remain rate-limited to avoid the hot-loop from
kubernetes#42715 where the controller's own status writes would
re-trigger continuous reconciliation. When HPAGeneration is disabled,
all updates fall back to rate-limited enqueue (the original behavior).
Type-assertion fallbacks in updateHPA (e.g. DeletedFinalStateUnknown)
now also use rate-limited enqueue to prevent any theoretical hot-loop.
The periodic resync cadence is unaffected: processNextWorkItem
continues to call AddRateLimited after every reconciliation cycle.
The client-go variant of ktesting is a superset of the normal
ktesting, which makes it possible to get the full original
functionality simply by changing the import path.