Skip to content

fix: sts_reconciler failure to retrieve historical StatefulSet revisions#77

Merged
Syspretor merged 1 commit intosgl-project:mainfrom
bcfre:fix-partition
Oct 28, 2025
Merged

fix: sts_reconciler failure to retrieve historical StatefulSet revisions#77
Syspretor merged 1 commit intosgl-project:mainfrom
bcfre:fix-partition

Conversation

@bcfre
Copy link
Copy Markdown
Collaborator

@bcfre bcfre commented Oct 28, 2025

Ⅰ. Motivation

fix: sts_reconciler failure to retrieve historical StatefulSet revisions

Ⅱ. Modifications

Align sts_reconciler StatefulSet revision listing label selector with available Pod retrieval logic, following StatefulSet controller’s revision creation behavior
https://github.com/kubernetes/kubernetes/blob/master/pkg/controller/statefulset/stateful_set_utils.go#L576-L581
RBG StatefulSet PodTemplate Label
https://github.com/sgl-project/rbg/blob/main/pkg/reconciler/sts_reconciler.go#L473-L474

Ⅲ. Does this pull request fix one issue?

fixes #76

Ⅳ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.

[AfterSuite] PASSED [0.031 seconds]

Ran 28 of 28 Specs in 133.556 seconds
SUCCESS! -- 28 Passed | 0 Failed | 0 Pending | 0 Skipped
--- PASS: TestE2E (133.56s)
PASS
ok sigs.k8s.io/rbgs/test/e2e 134.100s

Ⅴ. Describe how to verify it

#76

~ k get controllerrevision
NAME                            CONTROLLER                                      REVISION   AGE
rbg-example-55476cbfcf-2        rolebasedgroup.workloads.x-k8s.io/rbg-example   2          5m1s
rbg-example-5f6557855f-1        rolebasedgroup.workloads.x-k8s.io/rbg-example   1          7m38s
rbg-example-role-0-5b5ccc8994   statefulset.apps/rbg-example-role-0             1          8m43s
rbg-example-role-1-6b65c68658   statefulset.apps/rbg-example-role-1             2          5m
rbg-example-role-1-74c5b8f8db   statefulset.apps/rbg-example-role-1             1          8m47s
rbg-example-role-2-7c4b8b8796   statefulset.apps/rbg-example-role-2             1          8m46s

~ k get po
NAME                   READY   STATUS    RESTARTS   AGE
rbg-example-role-0-0   1/1     Running   0          8m45s
rbg-example-role-1-0   1/1     Running   0          3m58s
rbg-example-role-1-1   1/1     Running   0          4m31s
rbg-example-role-1-2   1/1     Running   0          3m20s
rbg-example-role-2-0   1/1     Running   0          8m48s

VI. Special notes for reviews

Checklist

  • Format your code make fmt.
  • Add unit tests or integration tests.
  • Update the documentation related to the change.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@RongGu RongGu requested a review from Copilot October 28, 2025 06:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug in the StatefulSet reconciler where historical ControllerRevision resources could not be retrieved due to an incorrect label selector. The fix aligns the revision listing logic with the Pod retrieval logic, matching Kubernetes' StatefulSet controller behavior.

Key Changes:

  • Updated getHighestRevision to use pod selector instead of role common labels for listing ControllerRevisions
  • Removed roleCommonLabels parameter from rollingUpdateParameters and getReplicaStates methods
  • Fixed test method call to use correct service name retrieval method

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
pkg/reconciler/sts_reconciler.go Removed roleCommonLabels parameter and updated getHighestRevision to use podSelector for proper ControllerRevision retrieval
pkg/reconciler/sts_reconciler_test.go Updated test to match new method signature without roleCommonLabels parameter
test/e2e/framework/workloads/statefulset_expect.go Fixed method call to use GetServiceName instead of GetWorkloadName

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/reconciler/sts_reconciler.go
@Syspretor
Copy link
Copy Markdown
Collaborator

/lgtm
/approve

@Syspretor Syspretor merged commit 9b06ef0 into sgl-project:main Oct 28, 2025
3 checks passed
@cheyang cheyang added this to the v0.5.0 milestone Oct 29, 2025
@bcfre bcfre deleted the fix-partition branch December 3, 2025 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Reconciler error: sts rbg-role-0 has no revision

5 participants