From 102863dd29fa3eda745cf5014775a71045a8be73 Mon Sep 17 00:00:00 2001 From: Anish Asthana Date: Thu, 4 Apr 2024 16:03:29 -0400 Subject: [PATCH 1/3] Disable MCAD by default Signed-off-by: Anish Asthana --- main.go | 15 +++++++++------ pkg/config/config.go | 4 +++- test/e2e/setup.sh | 10 ++++++++++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 04cd33ec2..42cc5a3e2 100644 --- a/main.go +++ b/main.go @@ -127,7 +127,8 @@ func main() { }, LeaderElection: &configv1alpha1.LeaderElectionConfiguration{}, }, - MCAD: &mcadconfig.MCADConfiguration{}, + MCADEnabled: pointer.Bool(false), + MCAD: &mcadconfig.MCADConfiguration{}, InstaScale: &config.InstaScaleConfiguration{ Enabled: pointer.Bool(false), InstaScaleConfiguration: instascaleconfig.InstaScaleConfiguration{ @@ -167,12 +168,14 @@ func main() { }) exitOnError(err, "unable to start manager") - mcadQueueController := mcad.NewJobController(mgr.GetConfig(), cfg.MCAD, &mcadconfig.MCADConfigurationExtended{}) - if mcadQueueController == nil { - // FIXME: update NewJobController so it follows Go idiomatic error handling and return an error instead of a nil object - os.Exit(1) + if pointer.BoolDeref(cfg.MCADEnabled, false) { + mcadQueueController := mcad.NewJobController(mgr.GetConfig(), cfg.MCAD, &mcadconfig.MCADConfigurationExtended{}) + if mcadQueueController == nil { + // FIXME: update NewJobController so it follows Go idiomatic error handling and return an error instead of a nil object + os.Exit(1) + } + mcadQueueController.Run(ctx.Done()) } - mcadQueueController.Run(ctx.Done()) if pointer.BoolDeref(cfg.InstaScale.Enabled, false) { instaScaleController := &instascale.AppWrapperReconciler{ diff --git a/pkg/config/config.go b/pkg/config/config.go index 10b547676..36234a3c6 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -32,7 +32,9 @@ type CodeFlareOperatorConfiguration struct { ControllerManager `json:",inline"` // The MCAD controller configuration - MCAD *mcad.MCADConfiguration `json:"mcad,omitempty"` + // MCADEnabled defaults to false + MCADEnabled *bool `json:"mcadEnabled,omitempty"` + MCAD *mcad.MCADConfiguration `json:"mcad,omitempty"` // The InstaScale controller configuration InstaScale *InstaScaleConfiguration `json:"instascale,omitempty"` diff --git a/test/e2e/setup.sh b/test/e2e/setup.sh index d5c99cbf8..1f8922aa8 100755 --- a/test/e2e/setup.sh +++ b/test/e2e/setup.sh @@ -56,3 +56,13 @@ roleRef: kind: ClusterRole name: mcad-controller-rayclusters EOF + +cat < Date: Fri, 5 Apr 2024 09:32:19 +0200 Subject: [PATCH 2/3] Enable MCAD in e2e tests --- config/e2e/config.yaml | 8 ++++++++ config/e2e/kustomization.yaml | 1 + main.go | 9 +++++---- pkg/config/config.go | 13 ++++++++++--- test/e2e/setup.sh | 10 ---------- 5 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 config/e2e/config.yaml diff --git a/config/e2e/config.yaml b/config/e2e/config.yaml new file mode 100644 index 000000000..4b01a4b0e --- /dev/null +++ b/config/e2e/config.yaml @@ -0,0 +1,8 @@ +kind: ConfigMap +apiVersion: v1 +metadata: + name: codeflare-operator-config +data: + config.yaml: | + mcad: + enabled: true diff --git a/config/e2e/kustomization.yaml b/config/e2e/kustomization.yaml index e06123b2a..772370da6 100644 --- a/config/e2e/kustomization.yaml +++ b/config/e2e/kustomization.yaml @@ -1,6 +1,7 @@ namespace: openshift-operators bases: +- config.yaml - ../default patches: diff --git a/main.go b/main.go index 42cc5a3e2..05a53f074 100644 --- a/main.go +++ b/main.go @@ -127,8 +127,9 @@ func main() { }, LeaderElection: &configv1alpha1.LeaderElectionConfiguration{}, }, - MCADEnabled: pointer.Bool(false), - MCAD: &mcadconfig.MCADConfiguration{}, + MCAD: &config.MCADConfiguration{ + Enabled: pointer.Bool(false), + }, InstaScale: &config.InstaScaleConfiguration{ Enabled: pointer.Bool(false), InstaScaleConfiguration: instascaleconfig.InstaScaleConfiguration{ @@ -168,8 +169,8 @@ func main() { }) exitOnError(err, "unable to start manager") - if pointer.BoolDeref(cfg.MCADEnabled, false) { - mcadQueueController := mcad.NewJobController(mgr.GetConfig(), cfg.MCAD, &mcadconfig.MCADConfigurationExtended{}) + if pointer.BoolDeref(cfg.MCAD.Enabled, false) { + mcadQueueController := mcad.NewJobController(mgr.GetConfig(), &cfg.MCAD.MCADConfiguration, &mcadconfig.MCADConfigurationExtended{}) if mcadQueueController == nil { // FIXME: update NewJobController so it follows Go idiomatic error handling and return an error instead of a nil object os.Exit(1) diff --git a/pkg/config/config.go b/pkg/config/config.go index 36234a3c6..85a03385c 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -32,9 +32,7 @@ type CodeFlareOperatorConfiguration struct { ControllerManager `json:",inline"` // The MCAD controller configuration - // MCADEnabled defaults to false - MCADEnabled *bool `json:"mcadEnabled,omitempty"` - MCAD *mcad.MCADConfiguration `json:"mcad,omitempty"` + MCAD *MCADConfiguration `json:"mcad,omitempty"` // The InstaScale controller configuration InstaScale *InstaScaleConfiguration `json:"instascale,omitempty"` @@ -46,6 +44,15 @@ type KubeRayConfiguration struct { RayDashboardOAuthEnabled *bool `json:"rayDashboardOAuthEnabled,omitempty"` } +type MCADConfiguration struct { + // enabled controls whether the MCAD controller is started. + // It defaults to false. + Enabled *bool `json:"enabled,omitempty"` + + // The InstaScale controller configuration + mcad.MCADConfiguration `json:",inline,omitempty"` +} + type InstaScaleConfiguration struct { // enabled controls whether the InstaScale controller is started. // It may default to true on platforms that InstaScale supports. diff --git a/test/e2e/setup.sh b/test/e2e/setup.sh index 1f8922aa8..d5c99cbf8 100755 --- a/test/e2e/setup.sh +++ b/test/e2e/setup.sh @@ -56,13 +56,3 @@ roleRef: kind: ClusterRole name: mcad-controller-rayclusters EOF - -cat < Date: Fri, 5 Apr 2024 10:03:18 +0200 Subject: [PATCH 3/3] Enable MCAD in OLM tests --- .github/workflows/olm_tests.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/olm_tests.yaml b/.github/workflows/olm_tests.yaml index aa8a3b172..b6932d893 100644 --- a/.github/workflows/olm_tests.yaml +++ b/.github/workflows/olm_tests.yaml @@ -92,6 +92,10 @@ jobs: echo Waiting for Deployment to be ready timeout 60 bash -c 'until [[ $(kubectl get deployment/codeflare-operator-manager -n '${{ env.SUBSCRIPTION_NAMESPACE }}') ]]; do sleep 5 && echo "$(kubectl get deployment/codeflare-operator-manager -n '${{ env.SUBSCRIPTION_NAMESPACE }}')"; done' kubectl wait -n ${{ env.SUBSCRIPTION_NAMESPACE }} deployment/codeflare-operator-manager --for=condition=Available=true --timeout=60s + + echo Patch the CodeFlare operator ConfigMap + kubectl patch -n '${{ env.SUBSCRIPTION_NAMESPACE }}' cm codeflare-operator-config --type merge -p '{"data":{"config.yaml":"mcad:\n enabled: true"}}' + env: CATALOG_SOURCE_NAME: "codeflare-olm-test" CATALOG_SOURCE_NAMESPACE: "olm"