Skip to content

fix(ops): support flat ordinal instance names - #10709

Draft
leon-ape wants to merge 1 commit into
mainfrom
bugfix/10704-flat-ordinal-ops
Draft

fix(ops): support flat ordinal instance names#10709
leon-ape wants to merge 1 commit into
mainfrom
bugfix/10704-flat-ordinal-ops

Conversation

@leon-ape

Copy link
Copy Markdown
Collaborator

What changed

  • replace deprecated OpsRequest pod-name generation with a shared InstanceNamePlan backed by instancetemplate.PodNameBuilder
  • preserve the running InstanceSet's status.assignedOrdinals when planning desired instance names
  • carry the canonical instance-name-to-template mapping through HorizontalScaling, Start, Stop, VerticalScaling, VolumeExpansion, and RebuildInstance
  • keep active and offline instance template mappings separate; recover flat offline-instance template metadata from retained PVC labels
  • add regression coverage for flat ordinals, named templates, retained assignments, and scale-out planning

Why

OpsRequest progress tracking generated legacy template-prefixed pod names even when the InstanceSet controller used flattened global ordinals. The expected names therefore never matched the actual pods, leaving affected operations pending or causing them to time out. Flat pod names also do not encode their instance template, so parsing the template from the name was incorrect.

Impact

OpsRequest progress tracking now uses the same naming implementation and ordinal assignments as the InstanceSet controller. Existing non-flat naming behavior remains covered by the operations test suite.

Validation

  • go test ./pkg/operations -count=1

Fixes #10704

@apecloud-bot

Copy link
Copy Markdown
Collaborator

Auto Cherry-pick Instructions

Usage:
  - /nopick: Not auto cherry-pick when PR merged.
  - /pick: release-x.x [release-x.x]: Auto cherry-pick to the specified branch when PR merged.

Example:
  - /nopick
  - /pick release-1.1

CLA Recheck Instructions

Usage:
  - /recheck-cla: Trigger a re-check of CLA status for this pull request.
Example:
  - /recheck-cla

@github-actions github-actions Bot added the size/L Denotes a PR that changes 100-499 lines. label Jul 22, 2026
@leon-ape leon-ape added the pick-1.1 Auto cherry-pick to release-1.1 when PR merged label Jul 22, 2026
lastCompSpec.Replicas = *lastCompConfiguration.Replicas
lastCompSpec.Instances = lastCompConfiguration.Instances
lastCompSpec.OfflineInstances = lastCompConfiguration.OfflineInstances
lastPlan, err := runtime.GenerateInstanceNamePlan(opsRes.Cluster.Namespace, clusterName, fullCompName, lastCompSpec)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

[P1] Do not reconstruct both the historical and desired participant sets from the current assignedOrdinals. getCreateAndDeletePodSet runs on every reconcile, while GenerateInstanceNamePlan seeds both plans from the live InstanceSet status. For example, with flat ordinals {0,2}, scaling 2 -> 3 initially identifies -1 as the new instance; after status converges to {0,1,2}, reconstructing the old 2-replica plan yields {0,1}, so the computed new instance changes to the already-existing -2. Because this path does not wait for the Component final state, Ops can report success while the actual new -1 is not ready. Participant identities must remain stable rather than being recomputed from an eventually changing workload status.

}
for _, ins := range rebuildInstance.Instances {
insTplName := appsv1.GetInstanceTemplateName(opsRes.Cluster.Name, rebuildInstance.ComponentName, ins.Name)
insTplName, ok := plan.TemplateByName[ins.Name]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

[P1] This rejects a retained-PVC-only/offline target that the Rebuild contract explicitly accepts. Action resolves such a target through GetInstance, and the later progress path has dedicated handling for an already-offline original instance. However, the name plan excludes every entry in OfflineInstances, so this lookup cannot find the target and returns a fatal error before the non-in-place rebuild starts. This affects both flat and non-flat naming and is a regression for the existing offline rebuild path.

func (r *opsRuntime) GenerateTemplateInstanceNames(clusterName, compName, templateName string, replicas int32, offlineInstances []string, ordinals appsv1.Ordinals) ([]string, error) {
workloadName := constant.GenerateWorkloadNamePattern(clusterName, compName)
ordinalList, err := instanceset.ConvertOrdinalsToSortedList(ordinals)
itsExt, err := instancetemplate.BuildInstanceSetExt(protoITS, nil)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

[P1] This moves the workloads controller authoritative instance-plan construction into Ops. The new Ops runtime synthesizes a partial InstanceSet, copies live status.assignedOrdinals, and directly invokes the internal instancetemplate planner. The base code already had deprecated name-generation debt, but this PR expands that dependency to workloads runtime state and allocation behavior. Ops should consume an explicit authoritative instance identity/template contract exposed by the owner API/status; it should not rerun the workloads plan builder.

offlineTemplateByName := make(map[string]string, len(compSpec.OfflineInstances))
if compSpec.FlatInstanceOrdinal && len(compSpec.OfflineInstances) > 0 {
offlineNames := sets.New(compSpec.OfflineInstances...)
volumes, err := r.loadVolumes(namespace, clusterName, compName)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

[P2] Retained PVC labels are not a complete contract for an offline instance template identity. A flat-ordinal offline instance may have no PVC, an older PVC without this label, or retained resources that have been removed; the public OfflineInstances API does not require this lookup to succeed. In those cases OfflineTemplateByName remains incomplete and offlineInstancesToOnline later fails fatally. The template association needs to be represented explicitly by the authoritative workloads/apps API instead of inferred from storage artifacts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pick-1.1 Auto cherry-pick to release-1.1 when PR merged size/L Denotes a PR that changes 100-499 lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpsRequest progress tracking never converges when FlatInstanceOrdinal is enabled

2 participants