Skip to content
Prev Previous commit
Next Next commit
updated operator/operand reconcile for userManaged
- so that controllers do not try to create/update/manage Subscription
  for an operator which is userManaged
- so that controllers do not spit out errors as it did previously
- so that controllers update OperandRequest with Running status
- operands in OperandConfig should still be created
- currently missing proper cleanup when OperandRequest is deleted

Signed-off-by: Henry Li <[email protected]>
  • Loading branch information
bitscuit committed Aug 28, 2024
commit c99b20f9c1b70b79cea4d9d9852b55084d32322c
12 changes: 7 additions & 5 deletions controllers/operandrequest/reconcile_operand.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,12 @@ 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.OperatorFailed, "", &r.Mutex)
continue
if !opdRegistry.UserManaged {
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.OperatorFailed, "", &r.Mutex)
continue
}
}

klog.V(3).Info("Generating customresource base on ClusterServiceVersion: ", csv.GetName())
Expand All @@ -185,7 +187,7 @@ func (r *Reconciler) reconcileOperand(ctx context.Context, requestInstance *oper
if err == nil {
// Check the requested Service Config if exist in specific OperandConfig
opdConfig := configInstance.GetService(operand.Name)
if opdConfig == nil {
if opdConfig == nil && !opdRegistry.UserManaged {
klog.V(2).Infof("There is no service: %s from the OperandConfig instance: %s/%s, Skip reconciling Operands", operand.Name, registryKey.Namespace, req.Registry)
continue
}
Expand Down
6 changes: 6 additions & 0 deletions controllers/operandrequest/reconcile_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ func (r *Reconciler) reconcileSubscription(ctx context.Context, requestInstance
return nil
}

if opt.UserManaged {
klog.Infof("Skip installing operator %s because it is managed by user", opt.PackageName)
requestInstance.SetMemberStatus(operand.Name, operatorv1alpha1.OperatorRunning, operatorv1alpha1.ServiceRunning, mu)
return nil
}

// Check subscription if exist
namespace := r.GetOperatorNamespace(opt.InstallMode, opt.Namespace)
sub, err := r.GetSubscription(ctx, opt.Name, namespace, registryInstance.Namespace, opt.PackageName)
Expand Down