From fe0678df108979e696114c227926d38c01b93cc4 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Fri, 19 Dec 2025 10:33:59 +0100 Subject: [PATCH] expose unreachble status of device --- api/core/v1alpha1/groupversion_info.go | 3 +++ internal/controller/core/device_controller.go | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/api/core/v1alpha1/groupversion_info.go b/api/core/v1alpha1/groupversion_info.go index 39b575469..ce6f35637 100644 --- a/api/core/v1alpha1/groupversion_info.go +++ b/api/core/v1alpha1/groupversion_info.go @@ -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" diff --git a/internal/controller/core/device_controller.go b/internal/controller/core/device_controller.go index 0dad1672b..fb7c765a0 100644 --- a/internal/controller/core/device_controller.go +++ b/internal/controller/core/device_controller.go @@ -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() { @@ -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,