Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/core/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ const (
// NotReadyReason indicates that the resource is not ready for use.
NotReadyReason = "NotReady"

// UnreachableReason indicates that the controller cannot reach the device.
UnreachableReason = "Unreachable"

// ReconcilePendingReason indicates that the controller is waiting for resources to be reconciled.
ReconcilePendingReason = "ReconcilePending"

Expand Down
7 changes: 6 additions & 1 deletion internal/controller/core/device_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ func (r *DeviceReconciler) reconcile(ctx context.Context, device *v1alpha1.Devic
}

if err := prov.Connect(ctx, conn); err != nil {
conditions.Set(device, metav1.Condition{
Type: v1alpha1.ReadyCondition,
Status: metav1.ConditionFalse,
Reason: v1alpha1.UnreachableReason,
Message: fmt.Sprintf("Failed to connect to provider: %v", err),
})
return fmt.Errorf("failed to connect to provider: %w", err)
}
defer func() {
Expand Down Expand Up @@ -292,7 +298,6 @@ func (r *DeviceReconciler) reconcile(ctx context.Context, device *v1alpha1.Devic
device.Status.SerialNumber = info.SerialNumber
device.Status.FirmwareVersion = info.FirmwareVersion
}

conditions.Set(device, metav1.Condition{
Type: v1alpha1.ReadyCondition,
Status: metav1.ConditionTrue,
Expand Down