From 8717b4f108baba69362f60809ce942d2b357504e Mon Sep 17 00:00:00 2001 From: Jiri Mencak Date: Sat, 17 Jan 2026 15:25:42 +0100 Subject: [PATCH] OCPBUGS-73757 --- pkg/operator/controller.go | 4 ++-- pkg/operator/mc.go | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/pkg/operator/controller.go b/pkg/operator/controller.go index 9a01b95aa6..1ce4c9badb 100644 --- a/pkg/operator/controller.go +++ b/pkg/operator/controller.go @@ -773,7 +773,7 @@ func (c *Controller) syncMachineConfig(labels map[string]string, profile *tunedv kernelArguments []string ) - pools, err := c.pc.getPoolsForMachineConfigLabelsSorted(labels) + pools, err := c.pc.getPoolsForMachineConfigNaming(labels) if err != nil { return err } @@ -1129,7 +1129,7 @@ func (c *Controller) getMachineConfigNamesForTuned() (map[string]bool, error) { continue } - pools, err := c.pc.getPoolsForMachineConfigLabels(recommend.MachineConfigLabels) + pools, err := c.pc.getPoolsForMachineConfigNaming(recommend.MachineConfigLabels) if err != nil { return nil, err } diff --git a/pkg/operator/mc.go b/pkg/operator/mc.go index b310fe4378..31bf6576a2 100644 --- a/pkg/operator/mc.go +++ b/pkg/operator/mc.go @@ -127,14 +127,27 @@ func (pc *ProfileCalculator) getPoolsForMachineConfigLabels(mcLabels map[string] return pools, nil } -// getPoolsForMachineConfigLabelsSorted is the same as getPoolsForMachineConfigLabels, but -// returns the MCPs alphabetically sorted by their names. -func (pc *ProfileCalculator) getPoolsForMachineConfigLabelsSorted(mcLabels map[string]string) ([]*mcfgv1.MachineConfigPool, error) { +// getPoolsForMachineConfigNaming calls getPoolsForMachineConfigLabels and sorts +// the MCPs alphabetically sorted by their names. Sorting has no special intent +// other than logging the pools always in the same order. If the special "worker" +// pool is found, it is returned instead of the alphabetically sorted MCP slice. +func (pc *ProfileCalculator) getPoolsForMachineConfigNaming(mcLabels map[string]string) ([]*mcfgv1.MachineConfigPool, error) { pools, err := pc.getPoolsForMachineConfigLabels(mcLabels) if err != nil { return nil, err } + // Check whether were matching "machineconfiguration.openshift.io/role": "worker" + // If so, we'll have the "worker" pool and return it. + for _, pool := range pools { + if pool == nil { + continue + } + if pool.Name == "worker" { + return []*mcfgv1.MachineConfigPool{pool}, nil + } + } + sort.Slice(pools, func(i, j int) bool { return pools[i].Name < pools[j].Name })