Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix operand phase error for Elasticsearch in OperandRequest #1049

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions api/v1alpha1/operandrequest_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 12 additions & 0 deletions controllers/operandrequest/operandrequest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion controllers/operandrequest/reconcile_operand.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

Expand Down