Skip to content

refactor: Read instance position and deployment from labels - #371

Draft
scotwells wants to merge 1 commit into
mainfrom
refactor/367-read-identity-from-labels
Draft

scotwells wants to merge 1 commit into
mainfrom
refactor/367-read-identity-from-labels

Conversation

@scotwells

Copy link
Copy Markdown
Contributor

Summary

Workload deployment names are about to become a short workload prefix plus a hash, so any code that reads meaning out of an instance name will break.

The controller took an instance's position from the digits at the end of its name, and the CLI found an instance's deployment by trimming those digits off. Both now read the position and the owning deployment from the labels and ownership the controller already records.

Instances with a missing or conflicting position label are now replaced instead of crashing the controller or silently shadowing another instance.

Test plan

  • Unit, controller and lint suites pass
  • Scaling a workload up and down creates and removes instances in position order
  • The CLI shows the workload and location for every instance under the new naming

Related to #367

WorkloadDeployment names are moving to a truncated workload name plus a
hash, so nothing may recover an ordinal or a deployment by splitting an
instance name. Code now reads identity from labels and owner references.

Key changes:
- The stateful strategy reads each existing instance's ordinal from the
  instance-index label and uses the loop index for instances it builds.
- Instances with a missing or invalid ordinal label, or a duplicate
  ordinal, are deleted ahead of other actions so a replacement can take
  the name. Previously a non-numeric suffix indexed the slice at -1.
- New instances get their own copy of the template labels. The shared
  map let the last ordinal written overwrite every other instance's label,
  which only went unnoticed because ordering came from the name.
- The CLI resolves an instance's deployment from the
  workload-deployment-name label or the WorkloadDeployment owner
  reference, and drops the name-splitting fallback.
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.

1 participant