Skip to content
Merged
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
69 changes: 40 additions & 29 deletions controllers/commonservice_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,35 +63,6 @@ const (

func (r *CommonServiceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {

if os.Getenv("NO_OLM") == "true" {
klog.Infof("Reconciling CommonService: %s in non OLM environment", req.NamespacedName)

klog.Infof("Start to Create ODLM CR in the namespace %s", r.Bootstrap.CSData.OperatorNs)
// Check if ODLM OperandRegistry and OperandConfig are created
klog.Info("Checking if OperandRegistry and OperandConfig CRD already exist")
existOpreg, _ := r.Bootstrap.CheckCRD(constant.OpregAPIGroupVersion, constant.OpregKind)
existOpcon, _ := r.Bootstrap.CheckCRD(constant.OpregAPIGroupVersion, constant.OpconKind)
// Install/update Opreg and Opcon resources before installing ODLM if CRDs exist
if existOpreg && existOpcon {

klog.Info("Installing/Updating OperandRegistry")
if err := r.Bootstrap.InstallOrUpdateOpreg(true, ""); err != nil {
klog.Errorf("Fail to Installing/Updating OperandConfig: %v", err)
return ctrl.Result{}, err
}

klog.Info("Installing/Updating OperandConfig")
if err := r.Bootstrap.InstallOrUpdateOpcon(true); err != nil {
klog.Errorf("Fail to Installing/Updating OperandConfig: %v", err)
return ctrl.Result{}, err
}
} else {
klog.Error("ODLM CRD not ready, waiting for it to be ready")
}

return ctrl.Result{}, nil
}

klog.Infof("Reconciling CommonService: %s", req.NamespacedName)

// Fetch the CommonService instance
Expand Down Expand Up @@ -124,6 +95,46 @@ func (r *CommonServiceReconciler) Reconcile(ctx context.Context, req ctrl.Reques
klog.Error("Accept license by changing .spec.license.accept to true in the CommonService CR. Operator will not proceed until then")
}

if os.Getenv("NO_OLM") == "true" {
klog.Infof("Reconciling CommonService: %s in non OLM environment", req.NamespacedName)

// create ibm-cpp-config configmap
if err := configurationcollector.CreateUpdateConfig(r.Bootstrap); err != nil {
klog.Errorf("Fail to reconcile %s/%s: %v", instance.Namespace, instance.Name, err)
return ctrl.Result{}, err
}

klog.Infof("Start to Create ODLM CR in the namespace %s", r.Bootstrap.CSData.OperatorNs)
// Check if ODLM OperandRegistry and OperandConfig are created
klog.Info("Checking if OperandRegistry and OperandConfig CRD already exist")
existOpreg, _ := r.Bootstrap.CheckCRD(constant.OpregAPIGroupVersion, constant.OpregKind)
existOpcon, _ := r.Bootstrap.CheckCRD(constant.OpregAPIGroupVersion, constant.OpconKind)
// Install/update Opreg and Opcon resources before installing ODLM if CRDs exist
if existOpreg && existOpcon {
klog.Info("Installing/Updating OperandRegistry")
if err := r.Bootstrap.InstallOrUpdateOpreg(true, ""); err != nil {
klog.Errorf("Fail to Installing/Updating OperandConfig: %v", err)
return ctrl.Result{}, err
}

klog.Info("Installing/Updating OperandConfig")
if err := r.Bootstrap.InstallOrUpdateOpcon(true); err != nil {
klog.Errorf("Fail to Installing/Updating OperandConfig: %v", err)
return ctrl.Result{}, err
}

// Temporary solution for EDB image ConfigMap reference
if err := r.Bootstrap.CreateEDBImageMaps(); err != nil {
klog.Errorf("Failed to create EDB Image ConfigMap: %v", err)
return ctrl.Result{}, err
}
} else {
klog.Error("ODLM CRD not ready, waiting for it to be ready")
}

return ctrl.Result{}, nil
}

// If the CommonService CR is not paused, continue to reconcile
if !r.reconcilePauseRequest(instance) {
if r.checkNamespace(req.NamespacedName.String()) {
Expand Down
Loading