Commit graph

295 commits

Author SHA1 Message Date
Maciej Szulik
7213a2099b
Move various one-time testFn inline
Signed-off-by: Maciej Szulik <soltysh@gmail.com>
2026-05-19 10:56:35 +02:00
Maciej Szulik
5cf02ebbcc
Use fakeclock in all tests
Signed-off-by: Maciej Szulik <soltysh@gmail.com>
2026-05-19 10:39:17 +02:00
Maciej Szulik
4993d95630
Speed up StatefulSet unit tests
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>
2026-05-19 10:15:30 +02:00
Joe Betz
119a1460c1
Generate deepcopy 2026-05-11 12:27:56 -04:00
Zhijun Liao
5d27870207
StatefulSet: Fix OnDelete strategy not updating CurrentRevision (#136833)
* Fix StatefulSet OnDelete strategy not updating CurrentRevision

Signed-off-by: Zhijun <dszhijun@gmail.com>

* Fix linter issue

Signed-off-by: Zhijun <dszhijun@gmail.com>

---------

Signed-off-by: Zhijun <dszhijun@gmail.com>
2026-05-05 21:12:24 +05:30
Maciej Szulik
12c48e2158
Squash similar statefulset updates tests under a single table driven test
Signed-off-by: Maciej Szulik <soltysh@gmail.com>
2026-04-30 11:06:00 +02:00
Maciej Szulik
de7588393c
Squash similar pod delete tests under a single table driven test
Signed-off-by: Maciej Szulik <soltysh@gmail.com>
2026-04-29 11:57:38 +02:00
Maciej Szulik
724b3372df
Cleanup statefulset controller helpers
- squash isFailed and isSucceeeded under single isTerminalPhase
- remove dropParentName in favor of getParentNameAndOrdinal

Signed-off-by: Maciej Szulik <soltysh@gmail.com>
2026-04-29 11:54:28 +02:00
Kubernetes Prow Robot
e0cae9a19e
Merge pull request #138451 from michaelasp/registerSTSMetric
Register Statefulset Metric for Reconcile skips
2026-04-24 02:58:45 +05:30
Maciej Szulik
de88e7598c
Parallel pod management should accordingly count old unavailable
and terminated pods for maxUnavailable

This change ensures that Parallel pod management in statefulset controller
counts old unavailable pods as candidates for rollouts, but leaving
terminating pods untouched. All the disruptions should always ensure
that the statefulset stays within defined maxUnavilable budget.

Signed-off-by: Maciej Szulik <soltysh@gmail.com>
2026-04-20 16:30:59 +02:00
Michael Aspinwall
0d78c8191d Register statefulset metrics for skips 2026-04-17 19:04:29 +00:00
Kubernetes Prow Robot
21b427c299
Merge pull request #136827 from atombrella/feature/fix_nilness_controller
Fix cases of nilness under pkg/controller.
2026-03-10 15:15:11 +05:30
ahmedharabi
a0dee17c1d statefulset: wrap errors with %w in StatefulPodControl
Signed-off-by: ahmedharabi <harabiahmed88@gmail.com>
2026-03-05 23:02:16 +01:00
Kubernetes Prow Robot
9d7dda7186
Merge pull request #137245 from atombrella/feature/slices_contains_pkg_controller
Update `pkg/controller` to use slices.Contains
2026-03-04 18:04:20 +05:30
Michael Aspinwall
c8e8bd5085 Add the ability for the statefulset controller to read its own writes 2026-02-27 18:21:30 +00:00
Mads Jensen
d11d54dc50 Update pkg/controller to use slices.Contains 2026-02-26 10:17:13 +01:00
Ryan Brewster
11c6f8c7c8
Clean up redundant IsNotFound checks in stateful_set_control
🏠 Remote-Dev: homespace
2026-02-12 14:35:10 +00:00
Mads Jensen
af5741da5f Fix cases of nilness under pkg/controller. 2026-02-07 21:16:00 +01:00
Ryan Brewster
efe3667b6b
Add 404 handling for the statefulset controller pod deletion codepath
The daemonset controller already has handling for NotFound errors.

Right now if the statefulset controller is attempting to scale down a
statefulset and its informer cache is stale, it can get hard-blocked on a
missing pod.

This issue will eventually self-resolve once the informer cache "catches
up", but in the process of exploring this issue I realized that
404s during pod deletions don't strictly need to abort the entire sync;
we can continue.

This is especially impactful for large statefulsets with
podManagementStrategy: Parallel, where a single "phantom" pod (actually
missing, but still present in the informer cache) can block thousands of
other pods from being cleaned up.
2026-02-06 22:45:57 +00:00
Karthik Bhat
e44e06c53f Remove usage of deprecated functions from ktesting package 2026-01-29 14:51:59 +05:30
Jefftree
2522628780 Add index for controller revision 2026-01-13 19:46:34 +00:00
Filip Křepinský
7aa186fa0a
schedule pod availability checks at the correct time in StatefulSets (#135428)
* wire now (time) to the availability checks in the StatefulSet controller

- this helps to make the controller reconcilliation consistent

* schedule pod availability checks at the correct time in StatefulSets

* replace "k8s.io/klog/v2/ktesting" with "k8s.io/kubernetes/test/utils/ktesting"

for advanced features (e.g. Eventually)

* add StatefulSetAvailabilityCheck test
2025-12-17 22:35:21 -08:00
Kubernetes Prow Robot
48c56e04e0
Merge pull request #135017 from liggitt/stateful-set-noop-rollout
Fix spurious statefulset rollout from 1.33 → 1.34
2025-11-03 19:58:11 -08:00
Jordan Liggitt
979c442774
Fix spurious workload rollout due to null creationTimestamp in controller revisions 2025-11-03 17:11:06 -05:00
Jordan Liggitt
94e085e15c
Add unit test detecting spurious statefulset rollout 2025-11-03 16:33:39 -05:00
Ondra Kupka
502186ca93 controller/statefulset: Improve goroutine mgmt
Make sure all threads are terminated when Run returns.
2025-10-29 19:04:37 +01:00
Kubernetes Prow Robot
57c243f33c
Merge pull request #134450 from mayank-agrwl/controller-contextual-logs
Replace HandleCrash and HandleError calls to use context-aware alternatives
2025-10-23 00:49:02 -07:00
Jordan Liggitt
91d135f344
Include relevant dimensions in pod controller indexing 2025-10-16 13:27:50 -04:00
Mayank Agrawal
5e216ae34d Replace HandleCrash and HandleError calls to use context-aware alternatives 2025-10-07 22:40:10 -07:00
Edwin Hernandez
fa9071302f
Adding metrics for Maxunavailable feature in StatefulSet (#130951)
* adding maxunavailable_violation metric

added metric to list of stable metrics

changed when metric gets incremented

addressed comments

fixed stable metrics list

* Update pkg/controller/statefulset/metrics/metrics.go

Co-authored-by: Filip Křepinský <fkrepins@redhat.com>

* Update the metric and log verbosity level

* Address false positives metric count

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* Implement maxUnavailable and UnavailableReplicas metrics

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* fix lint fmt

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* update tests

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* se metrics to 1 as a default

* log for true validation only and update func sig.

* Move maxUnavailable metric to the updateStatefulSetStatus

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* change metrics stability level to Alpha

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* fix unit test

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* fix linting issue

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

* Address code review feedback

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>

---------

Signed-off-by: Heba Elayoty <heelayot@microsoft.com>
Co-authored-by: Filip Křepinský <fkrepins@redhat.com>
Co-authored-by: Heba Elayoty <heelayot@microsoft.com>
2025-09-17 05:34:14 -07:00
Kubernetes Prow Robot
d03d25f47c
Merge pull request #133985 from aditigupta96/api-waitfornamedcachesync-with-context
Replace WaitForNamedCacheSync with WaitForNamedCacheSyncWithContext in pkg/controller/
2025-09-16 17:18:09 -07:00
Aditi Gupta
af231d2153 Replace WaitForNamedCacheSync with WaitForNamedCacheSyncWithContext in pkg/controller/ 2025-09-16 14:51:34 -07:00
Maciej Szulik
46cc610e6f
Drop PodIndexLabel after the feature GA-ed in 1.32
Signed-off-by: Maciej Szulik <soltysh@gmail.com>
2025-09-11 19:32:48 +02:00
Nour
72847ee1f7
Replace deprecated strings.Title with cases.Title 2025-08-30 18:16:59 +03:00
Maciej Szulik
09e357d31f
Drop StatefulSetAutoDeletePVC after the feature GA-ed in 1.32
Signed-off-by: Maciej Szulik <soltysh@gmail.com>
2025-08-28 13:35:16 +02:00
Kubernetes Prow Robot
66cf6286a8
Merge pull request #130909 from Edwinhr716/minreadyseconds-fix
Fix StatefulSetMinReadySeconds healthy concept
2025-07-07 12:31:26 -07:00
Heba Elayoty
977c670733
Add unit tests for minReady new behaviour
Signed-off-by: Heba Elayoty <heelayot@microsoft.com>
2025-07-01 18:05:26 -07:00
Michal Wozniak
ac86e67b7d Commonize filtering of Pods by Owner with all orphans in namespace 2025-06-30 08:07:21 +02:00
xigang
66c611125c Add namespace-aware orphan pod indexing
Signed-off-by: xigang <wangxigang2014@gmail.com>
2025-06-19 16:32:20 +08:00
Harish Kuna
c005b85d4d Reduce locking duration on cache to fetch data from Cache 2025-03-21 15:23:08 +00:00
Edwinhr716
8db5f06183 adding commits of the original PR
isHealthy -> isUnavailable, fixed comments

fixed reversed logic

changed logs from unhealthy to unavailable
2025-03-20 22:46:38 +00:00
Arda Güçlü
a88e08c397 Do not attempt to truncate revision history if revisionHistoryLimit is negative 2024-12-19 11:35:29 +03: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
Kubernetes Prow Robot
50362ac7d0 Promote StatefulSetAutoDeletePVC to stable for 1.32. 2024-11-07 09:43:49 -08:00
Alay Patel
3e3276e9fe
Promote PodIndexLabel for Statefulset and IndexedJob stable (#128387)
* lock feature gate for PodIndexLabel and mark it GA

Signed-off-by: Alay Patel <alayp@nvidia.com>

* add emulated version if testing disabling of PodIndexLabel FG

Signed-off-by: Alay Patel <alayp@nvidia.com>

---------

Signed-off-by: Alay Patel <alayp@nvidia.com>
2024-11-04 19:11:28 +00:00
Kubernetes Prow Robot
aa8f2878a5
Merge pull request #117943 from lowang-bh/lessFunCall
improve: reduce function calling number
2024-10-24 04:52:52 +01: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
Peter Schuurman
585971431b Remove StatefulSetStartOrdinal feature gate to target stable in 1.31 2024-07-16 08:05:09 -07:00
Matthew Cary
d386d6880e Respect controllers on PVCs for retention policy 2024-06-05 12:06:41 -07:00