diff --git a/controllers/fenceagentsremediation_controller.go b/controllers/fenceagentsremediation_controller.go index 9ab33c55..10aaf754 100644 --- a/controllers/fenceagentsremediation_controller.go +++ b/controllers/fenceagentsremediation_controller.go @@ -273,12 +273,17 @@ func updateConditions(reason v1alpha1.ConditionsChangeReason, currentConditions processingConditionStatus = metav1.ConditionFalse fenceAgentActionSucceededConditionStatus = metav1.ConditionFalse succeededConditionStatus = metav1.ConditionFalse - if reason == v1alpha1.RemediationFinishedNodeNotFound { + // Different reasons share the same effect to the conditions, but they have different message + switch reason { + case v1alpha1.RemediationFinishedNodeNotFound: conditionMessage = v1alpha1.RemediationFinishedNodeNotFoundConditionMessage - } else { + case v1alpha1.RemediationInterruptedByNHC: conditionMessage = v1alpha1.RemediationInterruptedByNHCConditionMessage + default: + err := fmt.Errorf("unknown ConditionsChangeReason:%s", reason) + log.Error(err, "couldn't update FAR Status Conditions") + return err } - case v1alpha1.RemediationStarted: processingConditionStatus = metav1.ConditionTrue fenceAgentActionSucceededConditionStatus = metav1.ConditionUnknown diff --git a/controllers/fenceagentsremediation_controller_test.go b/controllers/fenceagentsremediation_controller_test.go index 9a58e11e..51e0f67a 100644 --- a/controllers/fenceagentsremediation_controller_test.go +++ b/controllers/fenceagentsremediation_controller_test.go @@ -166,7 +166,7 @@ var _ = Describe("FAR Controller", func() { testVADeletion(vaName2, resourceDeletionWasTriggered) testPodDeletion(testPodName, resourceDeletionWasTriggered) - By("Having Succeed condition set to true") + By("Having Succeeded, FenceAgentActionSucceeded conditions set to true, and Processing set to false") verifyStatusCondition(workerNode, commonConditions.ProcessingType, conditionStatusPointer(metav1.ConditionFalse)) verifyStatusCondition(workerNode, v1alpha1.FenceAgentActionSucceededType, conditionStatusPointer(metav1.ConditionTrue)) verifyStatusCondition(workerNode, commonConditions.SucceededType, conditionStatusPointer(metav1.ConditionTrue)) @@ -199,7 +199,7 @@ var _ = Describe("FAR Controller", func() { testVADeletion(vaName2, resourceDeletionWasTriggered) testPodDeletion(testPodName, resourceDeletionWasTriggered) - By("Not having any condition set") + By("Having all three conditions set to false") verifyStatusCondition(dummyNode, commonConditions.ProcessingType, conditionStatusPointer(metav1.ConditionFalse)) verifyStatusCondition(dummyNode, v1alpha1.FenceAgentActionSucceededType, conditionStatusPointer(metav1.ConditionFalse)) verifyStatusCondition(dummyNode, commonConditions.SucceededType, conditionStatusPointer(metav1.ConditionFalse))