Skip to content

Commit

Permalink
fix machine reconcilation bug
Browse files Browse the repository at this point in the history
Signed-off-by: Prajyot-Parab <[email protected]>
  • Loading branch information
Prajyot-Parab committed Jul 24, 2023
1 parent d6512a8 commit 4c56d97
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion api/v1beta2/conditions_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ const (
// InstanceErroredReason instance is in a errored state.
InstanceErroredReason = "InstanceErrored"

// InstanceNotReadyReason used when the instance is in a pending state.
// InstanceNotReadyReason used when the instance is in a not ready state.
InstanceNotReadyReason = "InstanceNotReady"

// InstanceStateUnknownReason used when the instance is in a unknown state.
InstanceStateUnknownReason = "InstanceStateUnknown"
)

const (
Expand Down
8 changes: 8 additions & 0 deletions cloud/scope/powervs_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ func (m *PowerVSMachineScope) CreateMachine() (*models.PVMInstanceReference, err
} else if instanceReply != nil {
// TODO need a reasonable wrapped error.
return instanceReply, nil
} else if instanceReply == nil {
// Check if create request has been already triggered.
// If InstanceReadyCondition is Unknown then return and wait for it to get updated.
for _, con := range m.IBMPowerVSMachine.Status.Conditions {
if con.Type == infrav1beta2.InstanceReadyCondition && con.Status == corev1.ConditionUnknown {
return nil, nil
}
}
}
cloudInitData, err := m.GetBootstrapData()
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions controllers/ibmpowervsmachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ func (r *IBMPowerVSMachineReconciler) reconcileNormal(machineScope *scope.PowerV
machineScope.Info("PowerVS instance state is undefined", "state", *instance.Status, "instance-id", machineScope.GetInstanceID())
conditions.MarkUnknown(machineScope.IBMPowerVSMachine, infrav1beta2.InstanceReadyCondition, "", "")
}
} else {
machineScope.SetNotReady()
conditions.MarkUnknown(machineScope.IBMPowerVSMachine, infrav1beta2.InstanceReadyCondition, infrav1beta2.InstanceStateUnknownReason, "")
}

// Requeue after 2 minute if machine is not ready to update status of the machine properly.
Expand Down

0 comments on commit 4c56d97

Please sign in to comment.