Repository: red-hat-storage/ocs-client-operator
Pull request #365: upgrade noobaa along with client-operator
Author: login: leelavg
Labels: name: size/M
name: lgtm
name: approved
Created: 2025-05-12T14:21:25Z | Merged: 2025-05-14T07:47:59Z

in remote client clusters noobaa should follow client-operator subscription channel. we had tied noobaa feature usage with operator upgrade resulting in operator not upgrading from 4.17.

revert of #219 


Diff:
diff --git a/bundle/manifests/ocs-client-operator.clusterserviceversion.yaml b/bundle/manifests/ocs-client-operator.clusterserviceversion.yaml
index 7da5f1c9..01fad053 100644
--- a/bundle/manifests/ocs-client-operator.clusterserviceversion.yaml
+++ b/bundle/manifests/ocs-client-operator.clusterserviceversion.yaml
@@ -7,7 +7,7 @@ metadata:
     categories: Storage
     console.openshift.io/plugins: '["odf-client-console"]'
     containerImage: quay.io/ocs-dev/ocs-client-operator:latest
-    createdAt: "2025-04-15T05:54:04Z"
+    createdAt: "2025-05-12T14:17:40Z"
     description: OpenShift Data Foundation client operator enables consumption of
       storage services from a remote centralized OpenShift Data Foundation provider
       cluster.
@@ -463,8 +463,6 @@ spec:
                       fieldPath: metadata.name
                 - name: STATUS_REPORTER_IMAGE
                   value: quay.io/ocs-dev/ocs-client-operator:latest
-                - name: NOOBAA_OPERATOR_CHANNEL
-                  value: stable-4.17
                 image: quay.io/ocs-dev/ocs-client-operator:latest
                 livenessProbe:
                   httpGet:
diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml
index 7468e01b..2668f8cf 100644
--- a/config/manager/manager.yaml
+++ b/config/manager/manager.yaml
@@ -50,8 +50,6 @@ spec:
               fieldPath: metadata.name
         - name: STATUS_REPORTER_IMAGE
           value: STATUS_REPORTER_IMAGE_VALUE
-        - name: NOOBAA_OPERATOR_CHANNEL
-          value: stable-4.17
         securityContext:
           allowPrivilegeEscalation: false
         livenessProbe:
diff --git a/internal/controller/operatorconfigmap_controller.go b/internal/controller/operatorconfigmap_controller.go
index af8f3ead..1933bda2 100644
--- a/internal/controller/operatorconfigmap_controller.go
+++ b/internal/controller/operatorconfigmap_controller.go
@@ -598,8 +598,7 @@ func (c *OperatorConfigMapReconciler) ensureConsolePlugin() error {
 func (c *OperatorConfigMapReconciler) getNoobaaSubManagementConfig() bool {
 	valAsString, ok := c.operatorConfigMap.Data[manageNoobaaSubKey]
 	if !ok {
-		//while feature in dev preview returning false to disable feature by default.
-		return false
+		return true
 	}
 	val, err := strconv.ParseBool(valAsString)
 	if err != nil {
@@ -607,8 +606,7 @@ func (c *OperatorConfigMapReconciler) getNoobaaSubManagementConfig() bool {
 			err,
 			"Unsupported value under manageNoobaaSubscription key",
 		)
-		//while feature in dev preview returning false to disable feature by default.
-		return false
+		return true
 	}
 	return val
 }
@@ -700,15 +698,17 @@ func (c *OperatorConfigMapReconciler) reconcileClientOperatorSubscription() erro
 }
 
 func (c *OperatorConfigMapReconciler) reconcileNoobaaOperatorSubscription() error {
-	noobaaSubscription, err := c.getSubscriptionByPackageName("noobaa-operator")
+	noobaaSubscription, err := c.getSubscriptionByPackageName("mcg-operator")
+	if kerrors.IsNotFound(err) {
+		noobaaSubscription, err = c.getSubscriptionByPackageName("noobaa-operator")
+	}
 	if err != nil {
 		return err
 	}
-	desiredSubChannel := utils.GetNoobaaOperatorChannel()
-	if desiredSubChannel != noobaaSubscription.Spec.Channel {
-		noobaaSubscription.Spec.Channel = desiredSubChannel
+	if c.subscriptionChannel != "" && c.subscriptionChannel != noobaaSubscription.Spec.Channel {
+		noobaaSubscription.Spec.Channel = c.subscriptionChannel
 		if err := c.update(noobaaSubscription); err != nil {
-			return fmt.Errorf("failed to update subscription channel of 'noobaa-operator' to %v: %v", c.subscriptionChannel, err)
+			return fmt.Errorf("failed to update subscription channel of 'mcg-operator' to %v: %v", c.subscriptionChannel, err)
 		}
 	}
 	return nil
@@ -725,7 +725,7 @@ func (c *OperatorConfigMapReconciler) reconcileCSIAddonsOperatorSubscription() e
 	if c.subscriptionChannel != "" && c.subscriptionChannel != addonsSubscription.Spec.Channel {
 		addonsSubscription.Spec.Channel = c.subscriptionChannel
 		if err := c.update(addonsSubscription); err != nil {
-			return fmt.Errorf("failed to update subscription channel of 'csi-addons' to %v: %v", c.subscriptionChannel, err)
+			return fmt.Errorf("failed to update subscription channel of 'odf-csi-addons-operator' to %v: %v", c.subscriptionChannel, err)
 		}
 	}
 	return nil
diff --git a/pkg/utils/subscription.go b/pkg/utils/subscription.go
deleted file mode 100644
index b4404a06..00000000
--- a/pkg/utils/subscription.go
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-Copyright 2022 Red Hat, Inc.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package utils
-
-import (
-	"cmp"
-	"os"
-)
-
-var (
-	noobaaOperatorChannel = cmp.Or(os.Getenv("NOOBAA_OPERATOR_CHANNEL"), "latest")
-)
-
-func GetNoobaaOperatorChannel() string {
-	return noobaaOperatorChannel
-}


Reviews:
user: login: Madhu-1
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-14T07:25:42Z
user: login: Madhu-1
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-14T07:25:45Z
user: login: leelavg
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-14T07:30:19Z
user: login: leelavg
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-14T07:32:10Z
user: login: leelavg
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-14T07:37:01Z
user: login: Madhu-1
state: APPROVED
author_association: MEMBER
submitted_at: 2025-05-14T07:42:43Z
user: login: Madhu-1
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-05-14T07:44:39Z
user: login: leelavg
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-14T07:48:47Z

Review comments:
diff_hunk: @@ -598,17 +598,15 @@ func (c *OperatorConfigMapReconciler) ensureConsolePlugin() error {
 func (c *OperatorConfigMapReconciler) getNoobaaSubManagementConfig() bool {
 	valAsString, ok := c.operatorConfigMap.Data[manageNoobaaSubKey]
 	if !ok {
-		//while feature in dev preview returning false to disable feature by default.
-		return false
+		return true
 	}
 	val, err := strconv.ParseBool(valAsString)
 	if err != nil {
 		c.log.Error(
 			err,
 			"Unsupported value under manageNoobaaSubscription key",
 		)
-		//while feature in dev preview returning false to disable feature by default.
path: internal/controller/operatorconfigmap_controller.go
user: login: Madhu-1
body: Is this not dev-preview anymore? if not please update the commit message for this change as well.
created_at: 2025-05-14T07:25:42Z
author_association: MEMBER
diff_hunk: @@ -700,13 +698,15 @@ func (c *OperatorConfigMapReconciler) reconcileClientOperatorSubscription() erro
 }
 
 func (c *OperatorConfigMapReconciler) reconcileNoobaaOperatorSubscription() error {
-	noobaaSubscription, err := c.getSubscriptionByPackageName("noobaa-operator")
+	noobaaSubscription, err := c.getSubscriptionByPackageName("mcg-operator")
+	if kerrors.IsNotFound(err) {
+		noobaaSubscription, err = c.getSubscriptionByPackageName("noobaa-operator")
+	}
 	if err != nil {
 		return err
 	}
-	desiredSubChannel := utils.GetNoobaaOperatorChannel()
-	if desiredSubChannel != noobaaSubscription.Spec.Channel {
-		noobaaSubscription.Spec.Channel = desiredSubChannel
+	if c.subscriptionChannel != "" && c.subscriptionChannel != noobaaSubscription.Spec.Channel {
+		noobaaSubscription.Spec.Channel = c.subscriptionChannel
path: internal/controller/operatorconfigmap_controller.go
user: login: Madhu-1
body: The error mesasge at line 711 need to be updated to point to mcg-operator as well, currently its pointed to noobaa-operator only or is this fine?
created_at: 2025-05-14T07:25:45Z
author_association: MEMBER
diff_hunk: @@ -598,17 +598,15 @@ func (c *OperatorConfigMapReconciler) ensureConsolePlugin() error {
 func (c *OperatorConfigMapReconciler) getNoobaaSubManagementConfig() bool {
 	valAsString, ok := c.operatorConfigMap.Data[manageNoobaaSubKey]
 	if !ok {
-		//while feature in dev preview returning false to disable feature by default.
-		return false
+		return true
 	}
 	val, err := strconv.ParseBool(valAsString)
 	if err != nil {
 		c.log.Error(
 			err,
 			"Unsupported value under manageNoobaaSubscription key",
 		)
-		//while feature in dev preview returning false to disable feature by default.
path: internal/controller/operatorconfigmap_controller.go
user: login: leelavg
body: the issue was, the feature was incorrectly tied to upgrade which is wrong (mentioned in description). there is no change to feature state.

commit msg vs pr description, since we are doing merge commits, I'm increasingly updating the pr description rather than duplicating at multiple places if there needs to be a change (unless PR is addressing multiple issues/features) 😅 
created_at: 2025-05-14T07:30:19Z
author_association: CONTRIBUTOR
diff_hunk: @@ -700,13 +698,15 @@ func (c *OperatorConfigMapReconciler) reconcileClientOperatorSubscription() erro
 }
 
 func (c *OperatorConfigMapReconciler) reconcileNoobaaOperatorSubscription() error {
-	noobaaSubscription, err := c.getSubscriptionByPackageName("noobaa-operator")
+	noobaaSubscription, err := c.getSubscriptionByPackageName("mcg-operator")
+	if kerrors.IsNotFound(err) {
+		noobaaSubscription, err = c.getSubscriptionByPackageName("noobaa-operator")
+	}
 	if err != nil {
 		return err
 	}
-	desiredSubChannel := utils.GetNoobaaOperatorChannel()
-	if desiredSubChannel != noobaaSubscription.Spec.Channel {
-		noobaaSubscription.Spec.Channel = desiredSubChannel
+	if c.subscriptionChannel != "" && c.subscriptionChannel != noobaaSubscription.Spec.Channel {
+		noobaaSubscription.Spec.Channel = c.subscriptionChannel
path: internal/controller/operatorconfigmap_controller.go
user: login: leelavg
body: ah, it's u/s vs d/s, will change the preference to d/s.
created_at: 2025-05-14T07:32:10Z
author_association: CONTRIBUTOR
diff_hunk: @@ -700,13 +698,15 @@ func (c *OperatorConfigMapReconciler) reconcileClientOperatorSubscription() erro
 }
 
 func (c *OperatorConfigMapReconciler) reconcileNoobaaOperatorSubscription() error {
-	noobaaSubscription, err := c.getSubscriptionByPackageName("noobaa-operator")
+	noobaaSubscription, err := c.getSubscriptionByPackageName("mcg-operator")
+	if kerrors.IsNotFound(err) {
+		noobaaSubscription, err = c.getSubscriptionByPackageName("noobaa-operator")
+	}
 	if err != nil {
 		return err
 	}
-	desiredSubChannel := utils.GetNoobaaOperatorChannel()
-	if desiredSubChannel != noobaaSubscription.Spec.Channel {
-		noobaaSubscription.Spec.Channel = desiredSubChannel
+	if c.subscriptionChannel != "" && c.subscriptionChannel != noobaaSubscription.Spec.Channel {
+		noobaaSubscription.Spec.Channel = c.subscriptionChannel
path: internal/controller/operatorconfigmap_controller.go
user: login: leelavg
body: done.
created_at: 2025-05-14T07:37:01Z
author_association: CONTRIBUTOR
diff_hunk: @@ -598,17 +598,15 @@ func (c *OperatorConfigMapReconciler) ensureConsolePlugin() error {
 func (c *OperatorConfigMapReconciler) getNoobaaSubManagementConfig() bool {
 	valAsString, ok := c.operatorConfigMap.Data[manageNoobaaSubKey]
 	if !ok {
-		//while feature in dev preview returning false to disable feature by default.
-		return false
+		return true
 	}
 	val, err := strconv.ParseBool(valAsString)
 	if err != nil {
 		c.log.Error(
 			err,
 			"Unsupported value under manageNoobaaSubscription key",
 		)
-		//while feature in dev preview returning false to disable feature by default.
path: internal/controller/operatorconfigmap_controller.go
user: login: Madhu-1
body: its good to separate out different changes to own commit to provide clarity of the change. capturing the details on the git commit message is always helpful for tracking purpose.
created_at: 2025-05-14T07:44:39Z
author_association: MEMBER
diff_hunk: @@ -598,17 +598,15 @@ func (c *OperatorConfigMapReconciler) ensureConsolePlugin() error {
 func (c *OperatorConfigMapReconciler) getNoobaaSubManagementConfig() bool {
 	valAsString, ok := c.operatorConfigMap.Data[manageNoobaaSubKey]
 	if !ok {
-		//while feature in dev preview returning false to disable feature by default.
-		return false
+		return true
 	}
 	val, err := strconv.ParseBool(valAsString)
 	if err != nil {
 		c.log.Error(
 			err,
 			"Unsupported value under manageNoobaaSubscription key",
 		)
-		//while feature in dev preview returning false to disable feature by default.
path: internal/controller/operatorconfigmap_controller.go
user: login: leelavg
body: agreed, I follow that for features or if the PR is addressing more than 1 commit.
created_at: 2025-05-14T07:48:47Z
author_association: CONTRIBUTOR

PR comments:
user: login: leelavg
created_at: 2025-05-12T14:22:12Z
body: /cherrypick release-4.19
via [DFBUGS-1872](https://issues.redhat.com//browse/DFBUGS-1872)
author_association: CONTRIBUTOR
user: login: openshift-cherrypick-robot
created_at: 2025-05-12T14:22:16Z
body: @leelavg: once the present PR merges, I will cherry-pick it on top of `release-4.19` in a new PR and assign it to you.

<details>

In response to [this](https://github.com/red-hat-storage/ocs-client-operator/pull/365#issuecomment-2872780246):

>/cherrypick release-4.19
>via [DFBUGS-1872](https://issues.redhat.com//browse/DFBUGS-1872)


Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
</details>
author_association: NONE
user: login: leelavg
created_at: 2025-05-12T14:22:49Z
body: /hold

for upgrade testing.
author_association: CONTRIBUTOR
user: login: leelavg
created_at: 2025-05-13T06:33:17Z
body: /unhold

tested.
author_association: CONTRIBUTOR
user: login: openshift-ci[bot]
created_at: 2025-05-14T07:42:48Z
body: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/red-hat-storage/ocs-client-operator/pull/365#" title="Author self-approved">leelavg</a>*, *<a href="https://github.com/red-hat-storage/ocs-client-operator/pull/365#pullrequestreview-2839113447" title="Approved">Madhu-1</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=red-hat-storage%2Focs-client-operator).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/red-hat-storage/ocs-client-operator/blob/main/OWNERS)~~ [Madhu-1,leelavg]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
author_association: NONE
user: login: openshift-cherrypick-robot
created_at: 2025-05-14T07:48:40Z
body: @leelavg: new pull request created: #366

<details>

In response to [this](https://github.com/red-hat-storage/ocs-client-operator/pull/365#issuecomment-2872780246):

>/cherrypick release-4.19
>via [DFBUGS-1872](https://issues.redhat.com//browse/DFBUGS-1872)


Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
</details>
author_association: NONE