Skip to content
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

[release-4.11] OCPBUGS-5894: [wm_controller] Fix Machine node upgrades #1388

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 9 additions & 7 deletions controllers/windowsmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ func (r *WindowsMachineReconciler) Reconcile(ctx context.Context,
provisionedPhase := "Provisioned"
// runningPhase is the status of the machine when it is in the `Running` state, indicating that it is configured into a node
runningPhase := "Running"
// node is the Node object associated with the machine being reconciled, if any exists
var node *core.Node
if machine.Status.Phase == nil {
// This condition should never be true as machine objects without a phase will be filtered out via the predicate functions
return ctrl.Result{}, fmt.Errorf("could not get the phase associated with machine %s", machine.Name)
Expand All @@ -267,8 +269,8 @@ func (r *WindowsMachineReconciler) Reconcile(ctx context.Context,
// machine api operator
return ctrl.Result{}, fmt.Errorf("ready Windows machine %s missing NodeRef", machine.GetName())
}

node := &core.Node{}
// Populate the running Machine's Node object
node = &core.Node{}
err := r.client.Get(ctx, kubeTypes.NamespacedName{Namespace: machine.Status.NodeRef.Namespace,
Name: machine.Status.NodeRef.Name}, node)
if err != nil {
Expand Down Expand Up @@ -344,8 +346,8 @@ func (r *WindowsMachineReconciler) Reconcile(ctx context.Context,
}

log.Info("processing", "address", ipAddress)
// Make the Machine a Windows Worker node
if err := r.addWorkerNode(ipAddress, instanceID, machine.Name); err != nil {
// Configure the Machine as an up-to-date Windows Worker node
if err := r.configureMachine(ipAddress, instanceID, machine.Name, node); err != nil {
var authErr *windows.AuthErr
if errors.As(err, &authErr) {
// SSH authentication errors with the Machine are non recoverable, stemming from a mismatch with the
Expand Down Expand Up @@ -396,8 +398,8 @@ func (r *WindowsMachineReconciler) getDefaultUsername() string {
return "Administrator"
}

// addWorkerNode configures the given Windows VM, adding it as a node object to the cluster
func (r *WindowsMachineReconciler) addWorkerNode(ipAddress, instanceID, machineName string) error {
// configureMachine configures the given Windows VM, adding it as a node object to the cluster or upgrading it in place.
func (r *WindowsMachineReconciler) configureMachine(ipAddress, instanceID, machineName string, node *core.Node) error {
// The name of the Machine must be the same as the hostname of the associated VM. This is currently not true in the
// case of vSphere VMs provisioned by MAPI. In case of Linux, ignition was handling it. As we don't have an
// equivalent of ignition in Windows, WMCO must correct this by changing the VM's hostname.
Expand All @@ -408,7 +410,7 @@ func (r *WindowsMachineReconciler) addWorkerNode(ipAddress, instanceID, machineN
hostname = machineName
}
username := r.getDefaultUsername()
instanceInfo, err := instance.NewInfo(ipAddress, username, hostname, false, nil)
instanceInfo, err := instance.NewInfo(ipAddress, username, hostname, false, node)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/nodeutil/nodeutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

// FindByAddress returns a pointer to the node within the given list with an address matching the given address, or
// nil if the node was found.
// nil if the node was not found.
func FindByAddress(address string, nodes *core.NodeList) *core.Node {
for _, node := range nodes.Items {
for _, nodeAddress := range node.Status.Addresses {
Expand Down