Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/operator/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
19 changes: 16 additions & 3 deletions pkg/operator/mc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down