-
Notifications
You must be signed in to change notification settings - Fork 2
feat(node): track StatefulSet on Status, switch to typed Get+Update sync, pause scales to 0 #345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
fecd6bd
feat(node): track StatefulSet on Status, switch to typed Get+Update s…
bdchatham e17c26e
fixup: address Coral review — SSA-based sync, two-reconcile impostor …
bdchatham ae5aecc
chore: address lint + regen deepcopy for new StatefulSetRef
bdchatham dd2b4ba
chore: gofmt sync_test.go constant block
bdchatham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| package node | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
|
|
||
| seiv1alpha1 "github.com/sei-protocol/sei-k8s-controller/api/v1alpha1" | ||
| "github.com/sei-protocol/sei-k8s-controller/internal/noderesource" | ||
| ) | ||
|
|
||
| // reconcileStatefulSet syncs the owned StatefulSet via the typed | ||
| // Get+Create/Update helper and records the resulting object on | ||
| // Status.StatefulSet so subsequent reconciles fetch the tracked | ||
| // identity directly. | ||
| // | ||
| // A nil StatefulSet with no error means the impostor branch fired: | ||
| // SyncStatefulSet detected a UID mismatch, issued Delete, and deferred | ||
| // the Apply to the next reconcile. Leave Status.StatefulSet untouched — | ||
| // the stale UID still points at a now-deleted object, and the next | ||
| // reconcile (triggered by the StatefulSet delete watch event) observes | ||
| // NotFound and Applies a fresh STS whose new UID gets stamped onto | ||
| // Status.StatefulSet. | ||
| func (r *SeiNodeReconciler) reconcileStatefulSet(ctx context.Context, node *seiv1alpha1.SeiNode) error { | ||
| sts, err := noderesource.SyncStatefulSet(ctx, r.Client, r.Scheme, node, r.Platform) | ||
| if err != nil { | ||
| return fmt.Errorf("syncing statefulset: %w", err) | ||
| } | ||
| if sts == nil { | ||
| return nil | ||
| } | ||
| if node.Status.StatefulSet == nil || | ||
| node.Status.StatefulSet.UID != sts.UID || | ||
| node.Status.StatefulSet.Name != sts.Name { | ||
| node.Status.StatefulSet = &seiv1alpha1.StatefulSetRef{ | ||
| Name: sts.Name, | ||
| UID: sts.UID, | ||
| } | ||
| } | ||
| return nil | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impostor delete races with task creating orphaned StatefulSet
Medium Severity
When
reconcileStatefulSetdetects an impostor (UID mismatch), it deletes it and returnsnilwithout updatingStatus.StatefulSet. The controller then continues into the plan executor. If the active task isapply-statefulset, it callsSyncStatefulSetagain — this time the Get returns NotFound (impostor just deleted), so it falls through and creates a fresh StatefulSet. However,Status.StatefulSetstill holds the original stale UID (only the controller'sreconcileStatefulSetstamps it, and it skipped that onnil). On the next reconcile, the controller sees the task-created StatefulSet as another impostor and deletes it, causing unnecessary churn and a brief pod outage.Additional Locations (2)
internal/controller/node/controller.go#L114-L117internal/task/apply_statefulset.go#L56-L63Reviewed by Cursor Bugbot for commit ae5aecc. Configure here.