Skip to content

Commit fe0678d

Browse files
committed
expose unreachble status of device
1 parent 79d7e23 commit fe0678d

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎api/core/v1alpha1/groupversion_info.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ const (
9090
// NotReadyReason indicates that the resource is not ready for use.
9191
NotReadyReason = "NotReady"
9292

93+
// UnreachableReason indicates that the controller cannot reach the device.
94+
UnreachableReason = "Unreachable"
95+
9396
// ReconcilePendingReason indicates that the controller is waiting for resources to be reconciled.
9497
ReconcilePendingReason = "ReconcilePending"
9598

‎internal/controller/core/device_controller.go‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,12 @@ func (r *DeviceReconciler) reconcile(ctx context.Context, device *v1alpha1.Devic
239239
}
240240

241241
if err := prov.Connect(ctx, conn); err != nil {
242+
conditions.Set(device, metav1.Condition{
243+
Type: v1alpha1.ReadyCondition,
244+
Status: metav1.ConditionFalse,
245+
Reason: v1alpha1.UnreachableReason,
246+
Message: fmt.Sprintf("Failed to connect to provider: %v", err),
247+
})
242248
return fmt.Errorf("failed to connect to provider: %w", err)
243249
}
244250
defer func() {
@@ -292,7 +298,6 @@ func (r *DeviceReconciler) reconcile(ctx context.Context, device *v1alpha1.Devic
292298
device.Status.SerialNumber = info.SerialNumber
293299
device.Status.FirmwareVersion = info.FirmwareVersion
294300
}
295-
296301
conditions.Set(device, metav1.Condition{
297302
Type: v1alpha1.ReadyCondition,
298303
Status: metav1.ConditionTrue,

0 commit comments

Comments
 (0)