Skip to content

Commit 3dc3103

Browse files
committed
Filter machines being deleted from updatedReplicas count
UpToDateMachines method operates on `c.Machines` and removes the result of `c.MachinesNeedingRollout()` from it. This result doesn't include machines being deleted because MachinesNeedingRollout method removes them in the beginning of the definition using: ```go // Ignore machines to be deleted. machines := c.Machines.Filter(collections.Not(collections.HasDeletionTimestamp)) ``` Thus duplication of code to ensure machines being deleted aren't calculated in updatedReplicas
1 parent ce1ae57 commit 3dc3103

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pkg/rke2/control_plane.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,18 @@ func (c *ControlPlane) MachinesNeedingRollout() collections.Machines {
298298
)
299299
}
300300

301-
// UpToDateMachines returns the machines that are up to date with the control
301+
// UpToDateMachines returns the machines that are up-to-date with the control
302302
// plane's configuration and therefore do not require rollout.
303303
func (c *ControlPlane) UpToDateMachines() collections.Machines {
304-
return c.Machines.Difference(c.MachinesNeedingRollout())
304+
// Ignore machines to be deleted.
305+
machines := c.Machines.Filter(collections.Not(collections.HasDeletionTimestamp))
306+
// Filter machines if they are scheduled for rollout or if with an outdated configuration.
307+
machines.AnyFilter(
308+
// Machines that do not match with RCP config.
309+
collections.Not(matchesRCPConfiguration(c.infraResources, c.rke2Configs, c.RCP)),
310+
)
311+
312+
return machines.Difference(c.MachinesNeedingRollout())
305313
}
306314

307315
// getInfraResources fetches the external infrastructure resource for each machine in the collection

0 commit comments

Comments
 (0)