diff --git a/internal/controller/ready/controller.go b/internal/controller/ready/controller.go index b7ba7b5..813d583 100644 --- a/internal/controller/ready/controller.go +++ b/internal/controller/ready/controller.go @@ -184,11 +184,17 @@ func ComputeReadyCondition(hv *kvmv1.Hypervisor) metav1.Condition { // Priority 5: Onboarding not started, aborted, or not succeeded if onboardingCondition == nil { + message := "Onboarding not started" + if !hv.Spec.LifecycleEnabled { + message = "Onboarding not started: lifecycle management is disabled" + } else if hv.Status.HypervisorID == "" || hv.Status.ServiceID == "" { + message = "Onboarding not started: waiting for nova-compute to register the hypervisor in Nova (HypervisorID/ServiceID not yet available)" + } return metav1.Condition{ Type: kvmv1.ConditionTypeReady, Status: metav1.ConditionFalse, Reason: kvmv1.ConditionReasonOnboarding, - Message: "Onboarding not started", + Message: message, } } diff --git a/internal/controller/ready/controller_test.go b/internal/controller/ready/controller_test.go index 2a00f87..7e8783e 100644 --- a/internal/controller/ready/controller_test.go +++ b/internal/controller/ready/controller_test.go @@ -278,13 +278,39 @@ var _ = Describe("ComputeReadyCondition", func() { }) Context("Priority 5: Onboarding not started/aborted/not succeeded", func() { - It("should return Ready=False when no onboarding condition exists", func() { + It("should mention lifecycle disabled when lifecycleEnabled is false", func() { + hv.Spec.LifecycleEnabled = false + + result := ComputeReadyCondition(hv) + + Expect(result.Type).To(Equal(kvmv1.ConditionTypeReady)) + Expect(result.Status).To(Equal(metav1.ConditionFalse)) + Expect(result.Reason).To(Equal(kvmv1.ConditionReasonOnboarding)) + Expect(result.Message).To(ContainSubstring("lifecycle management is disabled")) + }) + + It("should mention waiting for nova-compute when HypervisorID/ServiceID are missing", func() { + hv.Spec.LifecycleEnabled = true + + result := ComputeReadyCondition(hv) + + Expect(result.Type).To(Equal(kvmv1.ConditionTypeReady)) + Expect(result.Status).To(Equal(metav1.ConditionFalse)) + Expect(result.Reason).To(Equal(kvmv1.ConditionReasonOnboarding)) + Expect(result.Message).To(ContainSubstring("waiting for nova-compute")) + }) + + It("should return generic not started when lifecycle is enabled and IDs are present", func() { + hv.Spec.LifecycleEnabled = true + hv.Status.HypervisorID = "some-id" + hv.Status.ServiceID = "some-service-id" + result := ComputeReadyCondition(hv) Expect(result.Type).To(Equal(kvmv1.ConditionTypeReady)) Expect(result.Status).To(Equal(metav1.ConditionFalse)) Expect(result.Reason).To(Equal(kvmv1.ConditionReasonOnboarding)) - Expect(result.Message).To(ContainSubstring("not started")) + Expect(result.Message).To(Equal("Onboarding not started")) }) It("should return Ready=False when onboarding was aborted", func() {