kubernetes-sigs / kubernetes-sigs/cluster-api
MachineSet with wrong MachineSetNameLabel value in .spec.selector spawns infinite Machines
Open
@aspr0d is already working on this.
Since May 14, 2026.
area/machine
area/machineset
help wanted
kind/bug
priority/important-longterm
triage/accepted
- Dominant language
- Go
- Stars
- 4.3k
- Forks
- 1.6k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 113
Description
What steps did you take and what happened?
Scaling up a CAPI MachineSet with a .spec.selector.matchLabels that has a k/v clusterv1.MachineSetNameLabel (cluster.x-k8s.io/set-name) with value that doesn't match the .metadata.name of the MachineSet, causes a infinite-loop of child Machines being created.
Reproducing steps:
- a CAPI MachineSet is created with matching
.spec.selector.matchLabelsand.spec.template.metadata.labels'scluster.x-k8s.io/set-namebut with its.metadata.namediffering from them - the CAPI MachineSet is scaled up to 1 replica by the user
- the CAPI MachineSet controller goes to create a machine, it sets the
.metadata.labelsvalue for the keyclusterv1.MachineSetNameLabelin the Machine by setting it to the parent MachineSet.metadata.name, ignoring what was specified in the.spec.template.metadata.labelsof the parent MachineSet - the CAPI Machine that gets created from the scale up has
.metadata.labelsdiffering from the one its parent MachineSet uses to select/find its children in the.spec.selector.matchingLabels - the CAPI machineset controller as such is unable to keep track if its children, and keeps creating new ones as the diff between owned machines and spec.replicas is always < 0
What did you expect to happen?
Only one Machine being created.
Cluster API version
Reproduced in v1.9.z, might be in all supported versions.
Kubernetes version
v1.32
Anything else you would like to add?
No response
Label(s) to be applied
/kind bug
/area machineset
/area machine
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.