diff --git a/api/v1alpha1/operandrequest_types.go b/api/v1alpha1/operandrequest_types.go index d99d416d..6a1651be 100644 --- a/api/v1alpha1/operandrequest_types.go +++ b/api/v1alpha1/operandrequest_types.go @@ -429,6 +429,15 @@ func (r *OperandRequest) RemoveServiceStatus(operatorName string, mu sync.Locker } } +func (r *OperandRequest) RemoveOperandPhase(name string, mu sync.Locker) { + mu.Lock() + defer mu.Unlock() + pos, m := getMemberStatus(&r.Status, name) + if m != nil { + r.Status.Members[pos].Phase = MemberPhase{} + } +} + func (r *OperandRequest) SetServiceStatus(ctx context.Context, service ServiceStatus, updater client.StatusClient, mu sync.Locker) error { mu.Lock() defer mu.Unlock() diff --git a/controllers/operandrequest/operandrequest_controller.go b/controllers/operandrequest/operandrequest_controller.go index 9d1c264f..96c45736 100644 --- a/controllers/operandrequest/operandrequest_controller.go +++ b/controllers/operandrequest/operandrequest_controller.go @@ -156,6 +156,18 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re return ctrl.Result{Requeue: true}, err } + // Clean the phase of each operand under spec.request.operand + for _, member := range requestInstance.Status.Members { + klog.V(2).Info("Cleaning the member status for Operand: ", member.Name) + requestInstance.RemoveOperandPhase(member.Name, &r.Mutex) + } + requestInstance.Status.Phase = operatorv1alpha1.ClusterPhaseNone + + if err := r.Client.Status().Update(ctx, requestInstance); err != nil { + klog.Errorf("failed to update the status of the OperandRequest %s: %v", req.NamespacedName.String(), err) + return ctrl.Result{}, err + } + // Reconcile Operators if err := r.reconcileOperator(ctx, requestInstance); err != nil { klog.Errorf("failed to reconcile Operators for OperandRequest %s: %v", req.NamespacedName.String(), err) diff --git a/controllers/operandrequest/reconcile_operand.go b/controllers/operandrequest/reconcile_operand.go index 69cbae26..91a76fcb 100644 --- a/controllers/operandrequest/reconcile_operand.go +++ b/controllers/operandrequest/reconcile_operand.go @@ -83,6 +83,7 @@ func (r *Reconciler) reconcileOperand(ctx context.Context, requestInstance *oper continue } + // Set no-op operator to Running status if opdRegistry.InstallMode == operatorv1alpha1.InstallModeNoop { requestInstance.SetNoSuitableRegistryCondition(registryKey.String(), opdRegistry.Name+" is in maintenance status", operatorv1alpha1.ResourceTypeOperandRegistry, corev1.ConditionTrue, &r.Mutex) requestInstance.SetMemberStatus(operand.Name, operatorv1alpha1.OperatorRunning, operatorv1alpha1.ServiceRunning, &r.Mutex) @@ -164,7 +165,7 @@ func (r *Reconciler) reconcileOperand(ctx context.Context, requestInstance *oper if len(requestList) == 0 || !util.Contains(requestList, requestInstance.Namespace+"."+requestInstance.Name+"."+operand.Name+"/request") { klog.Infof("Subscription %s in the namespace %s is NOT managed by %s/%s, Skip reconciling Operands", sub.Name, sub.Namespace, requestInstance.Namespace, requestInstance.Name) - requestInstance.SetMemberStatus(operand.Name, "", operatorv1alpha1.ServiceFailed, &r.Mutex) + requestInstance.SetMemberStatus(operand.Name, operatorv1alpha1.OperatorFailed, "", &r.Mutex) continue }