diff --git a/controllers/btpoperator_controller.go b/controllers/btpoperator_controller.go index e13300e6f..6c88a9370 100644 --- a/controllers/btpoperator_controller.go +++ b/controllers/btpoperator_controller.go @@ -249,7 +249,7 @@ func (r *BtpOperatorReconciler) setNewLeader(ctx context.Context, existingBtpOpe logger := log.FromContext(ctx) logger.Info(fmt.Sprintf("Found %d existing BtpOperators", len(existingBtpOperators.Items))) oldestCr := r.getOldestCR(existingBtpOperators) - if oldestCr.GetStatus().State == v1alpha1.StateError && oldestCr.IsReasonStringEqual(string(conditions.OlderCRExists)) { + if oldestCr.GetStatus().State == v1alpha1.StateWarning && oldestCr.IsReasonStringEqual(string(conditions.OlderCRExists)) { if err := r.UpdateBtpOperatorStatus(ctx, oldestCr, v1alpha1.StateProcessing, conditions.Processing, fmt.Sprintf("%s is the new leader", oldestCr.GetName())); err != nil { logger.Error(err, fmt.Sprintf("unable to set %s BtpOperator CR as the new leader", oldestCr.GetName())) @@ -283,8 +283,8 @@ func (r *BtpOperatorReconciler) getOldestCR(existingBtpOperators *v1alpha1.BtpOp func (r *BtpOperatorReconciler) HandleRedundantCR(ctx context.Context, oldestCr *v1alpha1.BtpOperator, cr *v1alpha1.BtpOperator) error { logger := log.FromContext(ctx) logger.Info("Handling redundant BtpOperator CR") - return r.UpdateBtpOperatorStatus(ctx, cr, v1alpha1.StateError, conditions.OlderCRExists, fmt.Sprintf("'%s' BtpOperator CR in '%s' namespace reconciles the module", - oldestCr.GetName(), oldestCr.GetNamespace())) + return r.UpdateBtpOperatorStatus(ctx, cr, v1alpha1.StateWarning, conditions.OlderCRExists, fmt.Sprintf("The '%s' BtpOperator CR in '%s' namespace reconciles the module. To use this CR to reconcile the module, delete the '%s' BtpOperator CR in the '%s' namespace and remove finalizers from the '%s' BtpOperator CR in the '%s' namespace.", + oldestCr.GetName(), oldestCr.GetNamespace(), oldestCr.GetName(), oldestCr.GetNamespace(), oldestCr.GetName(), oldestCr.GetNamespace())) } func (r *BtpOperatorReconciler) UpdateBtpOperatorStatus(ctx context.Context, cr *v1alpha1.BtpOperator, newState v1alpha1.State, reason conditions.Reason, message string) error { diff --git a/controllers/btpoperator_controller_cr_rotation_test.go b/controllers/btpoperator_controller_cr_rotation_test.go index 31a78ca69..2b5ee7612 100644 --- a/controllers/btpoperator_controller_cr_rotation_test.go +++ b/controllers/btpoperator_controller_cr_rotation_test.go @@ -57,13 +57,13 @@ var _ = Describe("BTP Operator CR leader replacement", func() { time.Sleep(1 * time.Second) btpOperator2 := createBtpOperator(secondBtpOperator) Eventually(func() error { return k8sClient.Create(ctx, btpOperator2) }).WithTimeout(k8sOpsTimeout).WithPolling(k8sOpsPollingInterval).Should(Succeed()) - Eventually(updateCh).Should(Receive(matchState(v1alpha1.StateError))) + Eventually(updateCh).Should(Receive(matchState(v1alpha1.StateWarning))) // required for later CreationTimestamp than btpOperator2 time.Sleep(1 * time.Second) btpOperator3 := createBtpOperator(thirdBtpOperator) Eventually(func() error { return k8sClient.Create(ctx, btpOperator3) }).WithTimeout(k8sOpsTimeout).WithPolling(k8sOpsPollingInterval).Should(Succeed()) - Eventually(updateCh).Should(Receive(matchState(v1alpha1.StateError))) + Eventually(updateCh).Should(Receive(matchState(v1alpha1.StateWarning))) btpOperators := &v1alpha1.BtpOperatorList{} Expect(k8sClient.List(ctx, btpOperators)).To(Succeed()) @@ -76,11 +76,11 @@ var _ = Describe("BTP Operator CR leader replacement", func() { }).WithTimeout(k8sOpsTimeout).WithPolling(k8sOpsPollingInterval).Should(BeTrue()) Eventually(func() (bool, error) { err := k8sClient.Get(ctx, client.ObjectKey{Namespace: defaultNamespace, Name: secondBtpOperator}, btpOperatorWithCurrentState) - return btpOperatorWithCurrentState.Status.State == v1alpha1.StateError && btpOperatorWithCurrentState.Status.Conditions[0].Reason == string(conditions.OlderCRExists), err + return btpOperatorWithCurrentState.Status.State == v1alpha1.StateWarning && btpOperatorWithCurrentState.Status.Conditions[0].Reason == string(conditions.OlderCRExists), err }).WithTimeout(k8sOpsTimeout).WithPolling(k8sOpsPollingInterval).Should(BeTrue()) Eventually(func() (bool, error) { err := k8sClient.Get(ctx, client.ObjectKey{Namespace: defaultNamespace, Name: thirdBtpOperator}, btpOperatorWithCurrentState) - return btpOperatorWithCurrentState.Status.State == v1alpha1.StateError && btpOperatorWithCurrentState.Status.Conditions[0].Reason == string(conditions.OlderCRExists), err + return btpOperatorWithCurrentState.Status.State == v1alpha1.StateWarning && btpOperatorWithCurrentState.Status.Conditions[0].Reason == string(conditions.OlderCRExists), err }).WithTimeout(k8sOpsTimeout).WithPolling(k8sOpsPollingInterval).Should(BeTrue()) Expect(k8sClient.Delete(ctx, btpOperator1)).To(Succeed()) @@ -97,7 +97,7 @@ var _ = Describe("BTP Operator CR leader replacement", func() { Eventually(func() (bool, error) { err := k8sClient.Get(ctx, client.ObjectKey{Namespace: defaultNamespace, Name: thirdBtpOperator}, btpOperatorWithCurrentState) - return btpOperatorWithCurrentState.Status.State == v1alpha1.StateError && btpOperatorWithCurrentState.Status.Conditions[0].Reason == string(conditions.OlderCRExists), err + return btpOperatorWithCurrentState.Status.State == v1alpha1.StateWarning && btpOperatorWithCurrentState.Status.Conditions[0].Reason == string(conditions.OlderCRExists), err }).WithTimeout(k8sOpsTimeout).WithPolling(k8sOpsPollingInterval).Should(BeTrue()) }) }) @@ -120,7 +120,7 @@ var _ = Describe("BTP Operator CR leader replacement", func() { time.Sleep(1 * time.Second) btpOperator2 := createBtpOperator(secondBtpOperator) Eventually(func() error { return k8sClient.Create(ctx, btpOperator2) }).WithTimeout(k8sOpsTimeout).WithPolling(k8sOpsPollingInterval).Should(Succeed()) - Eventually(updateCh).Should(Receive(matchState(v1alpha1.StateError))) + Eventually(updateCh).Should(Receive(matchState(v1alpha1.StateWarning))) btpOperators := &v1alpha1.BtpOperatorList{} Expect(k8sClient.List(ctx, btpOperators)).To(Succeed()) @@ -133,7 +133,7 @@ var _ = Describe("BTP Operator CR leader replacement", func() { }).WithTimeout(k8sOpsTimeout).WithPolling(k8sOpsPollingInterval).Should(BeTrue()) Eventually(func() (bool, error) { err := k8sClient.Get(ctx, client.ObjectKey{Namespace: defaultNamespace, Name: secondBtpOperator}, btpOperatorWithCurrentState) - return btpOperatorWithCurrentState.Status.State == v1alpha1.StateError && btpOperatorWithCurrentState.Status.Conditions[0].Reason == string(conditions.OlderCRExists), err + return btpOperatorWithCurrentState.Status.State == v1alpha1.StateWarning && btpOperatorWithCurrentState.Status.Conditions[0].Reason == string(conditions.OlderCRExists), err }).WithTimeout(k8sOpsTimeout).WithPolling(k8sOpsPollingInterval).Should(BeTrue()) Expect(k8sClient.Delete(ctx, btpOperator1)).To(Succeed()) diff --git a/docs/contributor/02-10-operations.md b/docs/contributor/02-10-operations.md index 7213ce92b..c48062284 100644 --- a/docs/contributor/02-10-operations.md +++ b/docs/contributor/02-10-operations.md @@ -111,7 +111,7 @@ Only one Condition of type `Ready` is used. | 15 | Error | Ready | false | GettingConfigMapFailed | Getting Config Map failed | | 16 | Error | Ready | false | InconsistentChart | Chart is inconsistent. Reconciliation initialized | | 17 | Error | Ready | false | InvalidSecret | sap-btp-manager secret does not contain required data - create proper secret | -| 18 | Error | Ready | false | OlderCRExists | This CR is not the oldest one so does not represent the module State | +| 18 | Warning | Ready | false | OlderCRExists | This CR is not the oldest one so does not represent the module State | | 19 | Error | Ready | false | PreparingInstallInfoFailed | Error while preparing installation information | | 20 | Error | Ready | false | ProvisioningFailed | Provisioning failed | | 21 | Error | Ready | false | ReconcileFailed | Reconciliation failed | diff --git a/internal/conditions/conditions.go b/internal/conditions/conditions.go index aff07c822..7ee8123fe 100644 --- a/internal/conditions/conditions.go +++ b/internal/conditions/conditions.go @@ -58,7 +58,7 @@ var Reasons = map[Reason]Metadata{ ChartInstallFailed: {Status: metav1.ConditionFalse, State: v1alpha1.StateError}, //Error;Failure during chart installation ConsistencyCheckFailed: {Status: metav1.ConditionFalse, State: v1alpha1.StateError}, //Error;Failure during consistency check Processing: {Status: metav1.ConditionFalse, State: v1alpha1.StateProcessing}, //Processing;Final State after deprovisioning - OlderCRExists: {Status: metav1.ConditionFalse, State: v1alpha1.StateError}, //Error;This CR is not the oldest one so does not represent the module State + OlderCRExists: {Status: metav1.ConditionFalse, State: v1alpha1.StateWarning}, //Warning;This CR is not the oldest one so does not represent the module State MissingSecret: {Status: metav1.ConditionFalse, State: v1alpha1.StateWarning}, //Warning;sap-btp-manager secret was not found - create proper secret InvalidSecret: {Status: metav1.ConditionFalse, State: v1alpha1.StateError}, //Error;sap-btp-manager secret does not contain required data - create proper secret HardDeleting: {Status: metav1.ConditionFalse, State: v1alpha1.StateDeleting}, //Deleting;Trying to hard delete