Skip to content

fix(rbgsa-controller): preserve and initialize readyReplicas#280

Merged
Syspretor merged 1 commit intosgl-project:mainfrom
sebest:fix/rbgsa-preserve-ready-replicas
Apr 22, 2026
Merged

fix(rbgsa-controller): preserve and initialize readyReplicas#280
Syspretor merged 1 commit intosgl-project:mainfrom
sebest:fix/rbgsa-preserve-ready-replicas

Conversation

@sebest
Copy link
Copy Markdown
Contributor

@sebest sebest commented Apr 21, 2026

Summary

  • bug: status.readyReplicas is reset to nil when status is updated
  • preserve RBGSA status fields by building SSA status patches from the latest live adapter
  • prevent later status applies from pruning status.readyReplicas back to nil
  • initialize status.readyReplicas to 0 when a bound adapter is created before the parent RBG has role status

Testing

  • go test ./internal/controller/workloads -count=1

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the RoleBasedGroupScalingAdapter controller to use a new patchAdapterStatus helper, ensuring status updates are performed against the latest object state from the API server. Additionally, it ensures ReadyReplicas is initialized to 0 when an adapter is bound without an existing role status. Feedback suggests optimizing the status patching logic by using a minimal apply configuration that only includes the object's identity and status, thereby avoiding the inclusion of the full Spec in status subresource updates.

Comment thread internal/controller/workloads/rolebasedgroupscalingadapter_controller.go Outdated
@sebest
Copy link
Copy Markdown
Contributor Author

sebest commented Apr 21, 2026

Addressed the open review comment in 3af25e88.

The RBGSA status patch helper now builds a status-only apply configuration instead of reusing the full object apply configuration, so /status SSA patches no longer carry spec. I also added a unit test to assert the status-patch helper excludes spec.

@sebest sebest force-pushed the fix/rbgsa-preserve-ready-replicas branch from 3af25e8 to 32a00f7 Compare April 21, 2026 08:44
Server-side-apply patches were being built from the in-memory adapter
status, which could lag the on-cluster state due to informer cache
staleness. When the resulting apply config omitted readyReplicas, SSA
cleared the field — dropping ready-replica observations during phase
transitions and scale operations.

- Add patchAdapterStatus() that reads the latest status via apiReader
  before building the apply config, so the patch always carries every
  status field this controller owns.
- Add a status-only apply-config factory so status patches cannot
  accidentally touch spec.
- Initialize readyReplicas to 0 on bind when the RBG has not yet
  reported a RoleStatus, so the field is always materialized in the
  apply config.
- Route all four status patch sites (unbound phase, bind, readyReplicas
  sync, scale) through the shared helper.
@sebest sebest force-pushed the fix/rbgsa-preserve-ready-replicas branch from 32a00f7 to f2ccf91 Compare April 22, 2026 05:38
Copy link
Copy Markdown
Collaborator

@Syspretor Syspretor left a comment

Choose a reason for hiding this comment

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

/lgtm

@Syspretor Syspretor merged commit f17b822 into sgl-project:main Apr 22, 2026
9 checks passed
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.

2 participants