Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions controllers/maasmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,12 @@ func (r *MaasMachineReconciler) reconcileNormal(ctx context.Context, machineScop
// VM just composed and is commissioning; requeue shortly
return ctrl.Result{RequeueAfter: 30 * time.Second}, nil
}
if errors.Is(err, maasmachine.ErrMachineCommissioning) {
// Machine is still commissioning in MaaS; we have no control over it during this stage
machineScope.Info("Machine is commissioning in MaaS; static IP configuration will be retried after commissioning completes")
conditions.MarkFalse(machineScope.MaasMachine, infrav1beta1.MachineDeployedCondition, infrav1beta1.MachineDeployingReason, clusterv1.ConditionSeverityInfo, "waiting for commissioning to complete")
return ctrl.Result{RequeueAfter: 30 * time.Second}, nil
}
machineScope.Error(err, "unable to create m")
conditions.MarkFalse(machineScope.MaasMachine, infrav1beta1.MachineDeployedCondition, infrav1beta1.MachineDeployFailedReason, clusterv1.ConditionSeverityError, err.Error())
return ctrl.Result{}, err
Expand Down
12 changes: 6 additions & 6 deletions pkg/maas/machine/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ import (

// Service manages the MaaS machine
var (
ErrBrokenMachine = errors.New("broken machine encountered")
ErrVMComposing = errors.New("vm composing/commissioning")
reHostID = regexp.MustCompile(`host (\d+)`)
reMachineID = regexp.MustCompile(`machine[s]? ([a-z0-9]{4,6})`)
ErrBrokenMachine = errors.New("broken machine encountered")
ErrVMComposing = errors.New("vm composing/commissioning")
ErrMachineCommissioning = errors.New("machine is commissioning")
reHostID = regexp.MustCompile(`host (\d+)`)
reMachineID = regexp.MustCompile(`machine[s]? ([a-z0-9]{4,6})`)
)

const (
Expand Down Expand Up @@ -827,8 +828,7 @@ func (s *Service) setMachineStaticIP(systemID string, config *infrav1beta1.Stati
// Special handling for Commissioning state: skip static IP configuration to avoid blocking commissioning
if machineState == "Commissioning" {
s.scope.Info("Machine is commissioning, skipping static IP configuration to avoid interfering with commissioning process. Will configure after commissioning completes", "systemID", systemID)
// Return error to requeue - static IP will be configured after commissioning completes
return fmt.Errorf("machine is commissioning, static IP configuration will be retried after commissioning completes")
return ErrMachineCommissioning
}
Comment on lines 847 to 851
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

Consider adding a unit test for this commissioning-path in setMachineStaticIP. Right now there are no tests asserting that when MAAS reports State() == "Commissioning", the method returns ErrMachineCommissioning (and that the error remains detectable via errors.Is after any wrapping). This is an important behavioral contract because the controller reconciliation flow depends on it for requeue behavior.

Copilot uses AI. Check for mistakes.

// For other non-allowed states, check if static IP is already correctly configured
Expand Down
Loading