kubernetes-sigs / kubernetes-sigs/cluster-api

Setting `md.spec.paused` to `true` should fully pause the MachineDeployment

Open
#8,629 20 comments 0 reactions 0 assignees View on GitHub
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?

- Create a legacy cluster with 1 MD
- Set `.spec.paused` of the MD to `true`
- Edit the MD to change `md.spec.replicas`

The MachineDeployment scales and creates new Machines.

### What did you expect to happen?

Pausing the MachineDeployment should fully pause its reconciliation.

Looking at the MachineDeployment reconciler code the following is the piece of code responsible for this behavior. We still sync the MD even if the MD is paused.

[/internal/controllers/machinedeployment/machinedeployment_controller.go#L266-L268](https://github.com/ykakarap/cluster-api/blob/c36f4c0e9599104f468012cf0bf223524d5c7d3e/internal/controllers/machinedeployment/machinedeployment_controller.go#L266-L268)
```go
if md.Spec.Paused {
return ctrl.Result{}, r.sync(ctx, md, msList)
}
```

Additional notes:
- Setting `md.spec.paused` to `true` will not create a new MS but will still reconcile changes that do no need a rollout.
- Setting the `cluster.x-k8s.io/paused` annotation will pause the MD completely.

It is better to have consistent behavior and and fully pause MD reconciliation if `md.spec.paused` is set to true.

### Cluster API version

`main`

### Kubernetes version

_No response_

### Anything else you would like to add?

_No response_

### Label(s) to be applied

/kind bug
One or more /area label. See https://github.com/kubernetes-sigs/cluster-api/labels?q=area for the list of labels.

Contributor guide

Open the contributing guide

Research direction

Start in internal/controllers/machinedeployment/machinedeployment_controller.go at the linked lines and trace how a paused MachineDeployment is reconciled. Reproduce the reported case by setting md.spec.paused to true and changing md.spec.replicas. Done means paused MachineDeployment reconciliation is fully stopped, consistently with the paused annotation behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.