From fdd7e59248884558580179fd408cd557c44682f7 Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Fri, 27 May 2022 13:38:16 +1000 Subject: [PATCH 1/2] replace allowOCM flag with a forceLocalOnly flag --- .../controllers/muo/muo_controller.go | 6 +- .../controllers/muo/muo_controller_test.go | 69 ++++++++++++------- 2 files changed, 48 insertions(+), 27 deletions(-) diff --git a/pkg/operator/controllers/muo/muo_controller.go b/pkg/operator/controllers/muo/muo_controller.go index 9cef6d5a0f0..ca0b9da5290 100644 --- a/pkg/operator/controllers/muo/muo_controller.go +++ b/pkg/operator/controllers/muo/muo_controller.go @@ -34,7 +34,7 @@ const ( controllerEnabled = "rh.srep.muo.enabled" controllerManaged = "rh.srep.muo.managed" controllerPullSpec = "rh.srep.muo.deploy.pullspec" - controllerAllowOCM = "rh.srep.muo.deploy.allowOCM" + controllerForceLocalOnly = "rh.srep.muo.deploy.forceLocalOnly" controllerOcmBaseURL = "rh.srep.muo.deploy.ocmBaseUrl" controllerOcmBaseURLDefaultValue = "https://api.openshift.com" @@ -96,8 +96,8 @@ func (r *Reconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl. Pullspec: pullSpec, } - allowOCM := instance.Spec.OperatorFlags.GetSimpleBoolean(controllerAllowOCM) - if allowOCM { + disableOCM := instance.Spec.OperatorFlags.GetSimpleBoolean(controllerForceLocalOnly) + if !disableOCM { useOCM := func() bool { var userSecret *corev1.Secret diff --git a/pkg/operator/controllers/muo/muo_controller_test.go b/pkg/operator/controllers/muo/muo_controller_test.go index e8811949647..2d577cd65cf 100644 --- a/pkg/operator/controllers/muo/muo_controller_test.go +++ b/pkg/operator/controllers/muo/muo_controller_test.go @@ -48,7 +48,8 @@ func TestMUOReconciler(t *testing.T) { }, mocks: func(md *mock_muo.MockDeployer, cluster *arov1alpha1.Cluster) { expectedConfig := &config.MUODeploymentConfig{ - Pullspec: "wonderfulPullspec", + Pullspec: "wonderfulPullspec", + EnableConnected: false, } md.EXPECT().CreateOrUpdate(gomock.Any(), cluster, expectedConfig).Return(nil) md.EXPECT().IsReady(gomock.Any()).Return(true, nil) @@ -62,7 +63,8 @@ func TestMUOReconciler(t *testing.T) { }, mocks: func(md *mock_muo.MockDeployer, cluster *arov1alpha1.Cluster) { expectedConfig := &config.MUODeploymentConfig{ - Pullspec: "acrtest.example.com/managed-upgrade-operator:aro-b1", + Pullspec: "acrtest.example.com/managed-upgrade-operator:aro-b4", + EnableConnected: false, } md.EXPECT().CreateOrUpdate(gomock.Any(), cluster, expectedConfig).Return(nil) md.EXPECT().IsReady(gomock.Any()).Return(true, nil) @@ -71,10 +73,10 @@ func TestMUOReconciler(t *testing.T) { { name: "managed, OCM allowed but pull secret entirely missing", flags: arov1alpha1.OperatorFlags{ - controllerEnabled: "true", - controllerManaged: "true", - controllerAllowOCM: "true", - controllerPullSpec: "wonderfulPullspec", + controllerEnabled: "true", + controllerManaged: "true", + controllerForceLocalOnly: "false", + controllerPullSpec: "wonderfulPullspec", }, mocks: func(md *mock_muo.MockDeployer, cluster *arov1alpha1.Cluster) { expectedConfig := &config.MUODeploymentConfig{ @@ -88,10 +90,10 @@ func TestMUOReconciler(t *testing.T) { { name: "managed, OCM allowed but empty pullsecret", flags: arov1alpha1.OperatorFlags{ - controllerEnabled: "true", - controllerManaged: "true", - controllerAllowOCM: "true", - controllerPullSpec: "wonderfulPullspec", + controllerEnabled: "true", + controllerManaged: "true", + controllerForceLocalOnly: "false", + controllerPullSpec: "wonderfulPullspec", }, pullsecret: "{\"auths\": {}}", mocks: func(md *mock_muo.MockDeployer, cluster *arov1alpha1.Cluster) { @@ -106,10 +108,10 @@ func TestMUOReconciler(t *testing.T) { { name: "managed, OCM allowed but mangled pullsecret", flags: arov1alpha1.OperatorFlags{ - controllerEnabled: "true", - controllerManaged: "true", - controllerAllowOCM: "true", - controllerPullSpec: "wonderfulPullspec", + controllerEnabled: "true", + controllerManaged: "true", + controllerForceLocalOnly: "false", + controllerPullSpec: "wonderfulPullspec", }, pullsecret: "i'm a little json, short and stout", mocks: func(md *mock_muo.MockDeployer, cluster *arov1alpha1.Cluster) { @@ -124,10 +126,10 @@ func TestMUOReconciler(t *testing.T) { { name: "managed, OCM connected mode", flags: arov1alpha1.OperatorFlags{ - controllerEnabled: "true", - controllerManaged: "true", - controllerAllowOCM: "true", - controllerPullSpec: "wonderfulPullspec", + controllerEnabled: "true", + controllerManaged: "true", + controllerForceLocalOnly: "false", + controllerPullSpec: "wonderfulPullspec", }, pullsecret: "{\"auths\": {\"" + pullSecretOCMKey + "\": {\"auth\": \"secret value\"}}}", mocks: func(md *mock_muo.MockDeployer, cluster *arov1alpha1.Cluster) { @@ -143,11 +145,11 @@ func TestMUOReconciler(t *testing.T) { { name: "managed, OCM connected mode, custom OCM URL", flags: arov1alpha1.OperatorFlags{ - controllerEnabled: "true", - controllerManaged: "true", - controllerAllowOCM: "true", - controllerOcmBaseURL: "https://example.com", - controllerPullSpec: "wonderfulPullspec", + controllerEnabled: "true", + controllerManaged: "true", + controllerForceLocalOnly: "false", + controllerOcmBaseURL: "https://example.com", + controllerPullSpec: "wonderfulPullspec", }, pullsecret: "{\"auths\": {\"" + pullSecretOCMKey + "\": {\"auth\": \"secret value\"}}}", mocks: func(md *mock_muo.MockDeployer, cluster *arov1alpha1.Cluster) { @@ -160,6 +162,24 @@ func TestMUOReconciler(t *testing.T) { md.EXPECT().IsReady(gomock.Any()).Return(true, nil) }, }, + { + name: "managed, pull secret exists, OCM disabled", + flags: arov1alpha1.OperatorFlags{ + controllerEnabled: "true", + controllerManaged: "true", + controllerForceLocalOnly: "true", + controllerPullSpec: "wonderfulPullspec", + }, + pullsecret: "{\"auths\": {\"" + pullSecretOCMKey + "\": {\"auth\": \"secret value\"}}}", + mocks: func(md *mock_muo.MockDeployer, cluster *arov1alpha1.Cluster) { + expectedConfig := &config.MUODeploymentConfig{ + Pullspec: "wonderfulPullspec", + EnableConnected: false, + } + md.EXPECT().CreateOrUpdate(gomock.Any(), cluster, expectedConfig).Return(nil) + md.EXPECT().IsReady(gomock.Any()).Return(true, nil) + }, + }, { name: "managed, MUO does not become ready", flags: arov1alpha1.OperatorFlags{ @@ -169,7 +189,8 @@ func TestMUOReconciler(t *testing.T) { }, mocks: func(md *mock_muo.MockDeployer, cluster *arov1alpha1.Cluster) { expectedConfig := &config.MUODeploymentConfig{ - Pullspec: "wonderfulPullspec", + Pullspec: "wonderfulPullspec", + EnableConnected: false, } md.EXPECT().CreateOrUpdate(gomock.Any(), cluster, expectedConfig).Return(nil) md.EXPECT().IsReady(gomock.Any()).Return(false, nil) From 4b99a89f92fcef889651fadcbadd98a5f63acb1b Mon Sep 17 00:00:00 2001 From: Amber Brown Date: Fri, 27 May 2022 13:38:26 +1000 Subject: [PATCH 2/2] upgrade image to b4 --- pkg/util/version/const.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/util/version/const.go b/pkg/util/version/const.go index a391c004ff0..8fe04988910 100644 --- a/pkg/util/version/const.go +++ b/pkg/util/version/const.go @@ -79,5 +79,5 @@ func MdsdImage(acrDomain string) string { // MUOImage contains the location of the Managed Upgrade Operator container image func MUOImage(acrDomain string) string { - return acrDomain + "/managed-upgrade-operator:aro-b1" + return acrDomain + "/managed-upgrade-operator:aro-b4" }