-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop unused labels from installer machineSets #182
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,9 +114,7 @@ func stubMachine() (*machinev1.Machine, error) { | |
Name: "aws-actuator-testing-machine", | ||
Namespace: defaultNamespace, | ||
Labels: map[string]string{ | ||
providerconfigv1.ClusterIDLabel: clusterID, | ||
providerconfigv1.MachineRoleLabel: "infra", | ||
providerconfigv1.MachineTypeLabel: "master", | ||
providerconfigv1.ClusterIDLabel: clusterID, | ||
}, | ||
Annotations: map[string]string{ | ||
// skip node draining since it's not mocked | ||
|
@@ -125,6 +123,12 @@ func stubMachine() (*machinev1.Machine, error) { | |
}, | ||
|
||
Spec: machinev1.MachineSpec{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Labels: map[string]string{ | ||
"node-role.kubernetes.io/master": "", | ||
"node-role.kubernetes.io/infra": "", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking through the PR I got the impression we were removing |
||
}, | ||
}, | ||
ProviderSpec: *providerSpec, | ||
}, | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -188,11 +188,26 @@ func providerConfigFromMachine(client client.Client, machine *machinev1.Machine, | |
} | ||
|
||
// isMaster returns true if the machine is part of a cluster's control plane | ||
func isMaster(machine *machinev1.Machine) bool { | ||
if machineType, exists := machine.ObjectMeta.Labels[providerconfigv1.MachineTypeLabel]; exists && machineType == "master" { | ||
return true | ||
func (a *Actuator) isMaster(machine *machinev1.Machine) (bool, error) { | ||
if machine.Status.NodeRef == nil { | ||
glog.Errorf("NodeRef not found in machine %s", machine.Name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As this can be transient should we log at |
||
return false, nil | ||
} | ||
return false | ||
node := &corev1.Node{} | ||
nodeKey := types.NamespacedName{ | ||
Namespace: machine.Status.NodeRef.Namespace, | ||
Name: machine.Status.NodeRef.Name, | ||
} | ||
|
||
err := a.client.Get(context.Background(), nodeKey, node) | ||
if err != nil { | ||
return false, fmt.Errorf("failed to get node from machine %s", machine.Name) | ||
} | ||
|
||
if _, exists := node.Labels["node-role.kubernetes.io/master"]; exists { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The rest of this can collapse to: _, exists := node.Labels["node-role.kubernetes.io/master"]
return exists |
||
return true, nil | ||
} | ||
return false, nil | ||
} | ||
|
||
// updateConditionCheck tests whether a condition should be updated from the | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Machine HC controller is still using the labels to filter out master nodes [1]. Do we have any replacement for it?
[1] https://github.com/openshift/machine-api-operator/blob/c4a348a011c07db7e3f864380b0134b318112d19/pkg/controller/machinehealthcheck/machinehealthcheck_controller.go#L335-L336
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will update mao as well. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
machine HC already validates from node role https://github.com/openshift/machine-api-operator/blob/c4a348a011c07db7e3f864380b0134b318112d19/pkg/controller/machinehealthcheck/machinehealthcheck_controller.go#L340-L360