Skip to content
Merged
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
17 changes: 2 additions & 15 deletions pkg/controller/machinehealthcheck/machinehealthcheck_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,30 +331,17 @@ func hasMatchingLabels(machineHealthCheck *healthcheckingv1alpha1.MachineHealthC
}

func isMaster(machine mapiv1.Machine, client client.Client) bool {
machineMasterLabels := []string{
"machine.openshift.io/cluster-api-machine-role",
"machine.openshift.io/cluster-api-machine-type",
"sigs.k8s.io/cluster-api-machine-role",
"sigs.k8s.io/cluster-api-machine-type",
}
nodeMasterLabels := []string{
masterLabels := []string{
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to check machine labels at all?
IMHO the only proper way is to check node labels that machine reference to.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"node-role.kubernetes.io/master",
}

machineLabels := labels.Set(machine.Labels)
for _, masterLabel := range machineMasterLabels {
if machineLabels.Get(masterLabel) == "master" {
return true
}
}

node, err := getNodeFromMachine(machine, client)
if err != nil {
glog.Warningf("Couldn't get node for machine %s", machine.Name)
return false
}
nodeLabels := labels.Set(node.Labels)
for _, masterLabel := range nodeMasterLabels {
for _, masterLabel := range masterLabels {
if nodeLabels.Has(masterLabel) {
return true
}
Expand Down