diff --git a/acceptance/main_test.go b/acceptance/main_test.go index 3ba0f044e..d45c223fb 100644 --- a/acceptance/main_test.go +++ b/acceptance/main_test.go @@ -70,7 +70,7 @@ func TestMain(m *testing.M) { "createAdditionalControllerCRs": true, "createRPKBundleCRs": true, }, - "additionalCmdFlags": []string{"--additional-controllers=all"}, + "additionalCmdFlags": []string{"--additional-controllers=all", "--enable-helm-controllers=false", "--force-defluxed-mode"}, }, }) t.Log("Successfully installed Redpanda operator chart") diff --git a/operator/cmd/run/run.go b/operator/cmd/run/run.go index 0f970960c..44cafe245 100644 --- a/operator/cmd/run/run.go +++ b/operator/cmd/run/run.go @@ -105,6 +105,7 @@ func Command() *cobra.Command { ghostbuster bool unbindPVCsAfter time.Duration autoDeletePVCs bool + forceDefluxedMode bool ) cmd := &cobra.Command{ @@ -136,6 +137,7 @@ func Command() *cobra.Command { ghostbuster, unbindPVCsAfter, autoDeletePVCs, + forceDefluxedMode, ) }, } @@ -166,6 +168,7 @@ func Command() *cobra.Command { cmd.Flags().BoolVar(&enableHelmControllers, "enable-helm-controllers", true, "if a namespace is defined and operator mode is true, this enables the use of helm controllers to manage fluxcd helm resources.") cmd.Flags().DurationVar(&unbindPVCsAfter, "unbind-pvcs-after", 0, "if not zero, runs the PVCUnbinder controller which attempts to 'unbind' the PVCs' of Pods that are Pending for longer than the given duration") cmd.Flags().BoolVar(&autoDeletePVCs, "auto-delete-pvcs", false, "Use StatefulSet PersistentVolumeClaimRetentionPolicy to auto delete PVCs on scale down and Cluster resource delete.") + cmd.Flags().BoolVar(&forceDefluxedMode, "force-defluxed-mode", false, "specifies the default value for useFlux of Redpanda CRs if not specified. May be used in conjunction with enable-helm-controllers=false") // 3rd party flags. clientOptions.BindFlags(cmd.Flags()) @@ -199,6 +202,7 @@ func Run( ghostbuster bool, unbindPVCsAfter time.Duration, autoDeletePVCs bool, + forceDefluxedMode bool, ) error { setupLog := ctrl.LoggerFrom(ctx).WithName("setup") @@ -360,10 +364,11 @@ func Run( // Redpanda Reconciler if err = (&redpandacontrollers.RedpandaReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - EventRecorder: mgr.GetEventRecorderFor("RedpandaReconciler"), - ClientFactory: internalclient.NewFactory(mgr.GetConfig(), mgr.GetClient()), + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + EventRecorder: mgr.GetEventRecorderFor("RedpandaReconciler"), + ClientFactory: internalclient.NewFactory(mgr.GetConfig(), mgr.GetClient()), + DefaultDisableFlux: forceDefluxedMode, }).SetupWithManager(ctx, mgr); err != nil { setupLog.Error(err, "unable to create controller", "controller", "Redpanda") return err diff --git a/operator/internal/controller/redpanda/redpanda_controller.go b/operator/internal/controller/redpanda/redpanda_controller.go index d57dbfd0c..335e6595c 100644 --- a/operator/internal/controller/redpanda/redpanda_controller.go +++ b/operator/internal/controller/redpanda/redpanda_controller.go @@ -78,10 +78,11 @@ type gvkKey struct { // RedpandaReconciler reconciles a Redpanda object type RedpandaReconciler struct { - Client client.Client - Scheme *runtime.Scheme - EventRecorder kuberecorder.EventRecorder - ClientFactory internalclient.ClientFactory + Client client.Client + Scheme *runtime.Scheme + EventRecorder kuberecorder.EventRecorder + ClientFactory internalclient.ClientFactory + DefaultDisableFlux bool } // flux resources main resources @@ -321,7 +322,7 @@ func (r *RedpandaReconciler) reconcileStatus(ctx context.Context, rp *v1alpha2.R func (r *RedpandaReconciler) reconcileDefluxed(ctx context.Context, rp *v1alpha2.Redpanda) error { log := ctrl.LoggerFrom(ctx) - if ptr.Deref(rp.Spec.ChartRef.UseFlux, true) { + if r.IsFluxEnabled(rp.Spec.ChartRef.UseFlux) { log.V(logger.TraceLevel).Info("useFlux is true; skipping non-flux reconciliation...") return nil } @@ -518,7 +519,7 @@ func (r *RedpandaReconciler) reconcileLicense(ctx context.Context, rp *v1alpha2. } func (r *RedpandaReconciler) reconcileClusterConfig(ctx context.Context, rp *v1alpha2.Redpanda) error { - if ptr.Deref(rp.Spec.ChartRef.UseFlux, true) { + if r.IsFluxEnabled(rp.Spec.ChartRef.UseFlux) { apimeta.SetStatusCondition(rp.GetConditions(), metav1.Condition{ Type: v1alpha2.ClusterConfigSynced, Status: metav1.ConditionUnknown, @@ -861,7 +862,7 @@ func (r *RedpandaReconciler) createHelmReleaseFromTemplate(ctx context.Context, OwnerReferences: []metav1.OwnerReference{rp.OwnerShipRefObj()}, }, Spec: helmv2beta2.HelmReleaseSpec{ - Suspend: !ptr.Deref(rp.Spec.ChartRef.UseFlux, true), + Suspend: !r.IsFluxEnabled(rp.Spec.ChartRef.UseFlux), Chart: helmv2beta2.HelmChartTemplate{ Spec: helmv2beta2.HelmChartTemplateSpec{ Chart: "redpanda", @@ -890,7 +891,7 @@ func (r *RedpandaReconciler) helmRepositoryFromTemplate(rp *v1alpha2.Redpanda) * OwnerReferences: []metav1.OwnerReference{rp.OwnerShipRefObj()}, }, Spec: sourcev1.HelmRepositorySpec{ - Suspend: !ptr.Deref(rp.Spec.ChartRef.UseFlux, true), + Suspend: !r.IsFluxEnabled(rp.Spec.ChartRef.UseFlux), Interval: metav1.Duration{Duration: 30 * time.Second}, URL: v1alpha2.RedpandaChartRepository, }, @@ -982,3 +983,7 @@ func allListTypes(c client.Client) ([]client.ObjectList, error) { } return types, nil } + +func (r *RedpandaReconciler) IsFluxEnabled(useFlux *bool) bool { + return ptr.Deref(useFlux, !r.DefaultDisableFlux) +} diff --git a/operator/internal/controller/redpanda/redpanda_controller_test.go b/operator/internal/controller/redpanda/redpanda_controller_test.go index 160c35f65..fc73e801e 100644 --- a/operator/internal/controller/redpanda/redpanda_controller_test.go +++ b/operator/internal/controller/redpanda/redpanda_controller_test.go @@ -983,6 +983,27 @@ func TestPostInstallUpgradeJobIndex(t *testing.T) { require.Equal(t, "bootstrap-yaml-envsubst", job.Spec.Template.Spec.InitContainers[0].Name) } +func TestIsFluxEnabled(t *testing.T) { + for _, tc := range []struct { + expected bool + expectedSuspended bool + useFluxCRD *bool + forceDefluxed bool + }{ + {true, false, ptr.To(true), false}, + {false, true, ptr.To(false), false}, + {true, false, nil, false}, + {true, false, ptr.To(true), true}, + {false, true, ptr.To(false), true}, + {false, true, nil, true}, + } { + r := redpanda.RedpandaReconciler{DefaultDisableFlux: tc.forceDefluxed} + assert.Equal(t, tc.expected, r.IsFluxEnabled(tc.useFluxCRD)) + // When it comes for helmrepository and helmrelease they should be suspended + assert.Equal(t, tc.expectedSuspended, !r.IsFluxEnabled(tc.useFluxCRD)) + } +} + // TestControllerRBAC asserts that the declared Roles and ClusterRoles of the // RedpandaReconciler line up with all the resource types it needs to manage. func TestControllerRBAC(t *testing.T) { diff --git a/operator/kuttl-v2-test.yaml b/operator/kuttl-v2-test.yaml index 53055bdf9..ae07e5cfd 100644 --- a/operator/kuttl-v2-test.yaml +++ b/operator/kuttl-v2-test.yaml @@ -17,7 +17,7 @@ commands: - command: helm repo update - command: helm install --set logLevel=trace --set image.tag=dev --set image.repository=localhost/redpanda-operator --namespace redpanda --create-namespace redpanda-operator - redpanda/operator --set rbac.createAdditionalControllerCRs=true --set additionalCmdFlags="{--additional-controllers=all}" + redpanda/operator --set rbac.createAdditionalControllerCRs=true --set additionalCmdFlags="{--additional-controllers=all,--force-defluxed-mode,--enable-helm-controllers=false}" --set rbac.createRPKBundleCRs=true --wait artifactsDir: tests/_e2e_artifacts_v2 timeout: 720 diff --git a/operator/tests/e2e-v2/connectors/00-assert-create-redpanda.yaml b/operator/tests/e2e-v2/connectors/00-assert-create-redpanda.yaml index 31641a84a..a37b72134 100644 --- a/operator/tests/e2e-v2/connectors/00-assert-create-redpanda.yaml +++ b/operator/tests/e2e-v2/connectors/00-assert-create-redpanda.yaml @@ -6,8 +6,6 @@ metadata: - operator.redpanda.com/finalizer name: rp-connectors spec: - chartRef: - chartVersion: "5.7.4" clusterSpec: statefulset: replicas: 1 diff --git a/operator/tests/e2e-v2/connectors/00-create-redpanda.yaml b/operator/tests/e2e-v2/connectors/00-create-redpanda.yaml index 903f3f62e..7adec04d1 100644 --- a/operator/tests/e2e-v2/connectors/00-create-redpanda.yaml +++ b/operator/tests/e2e-v2/connectors/00-create-redpanda.yaml @@ -4,8 +4,6 @@ kind: Redpanda metadata: name: rp-connectors spec: - chartRef: - chartVersion: "5.7.4" clusterSpec: statefulset: replicas: 1 diff --git a/operator/tests/e2e-v2/decommission/00-assert-create-redpanda.yaml b/operator/tests/e2e-v2/decommission/00-assert-create-redpanda.yaml index 5894c5973..b94b90ded 100644 --- a/operator/tests/e2e-v2/decommission/00-assert-create-redpanda.yaml +++ b/operator/tests/e2e-v2/decommission/00-assert-create-redpanda.yaml @@ -32,23 +32,6 @@ status: replicas: 5 updatedReplicas: 5 --- -apiVersion: helm.toolkit.fluxcd.io/v2beta2 -kind: HelmRelease -metadata: - name: decommission -status: - conditions: - - - reason: InstallSucceeded - status: "True" - type: Ready - - reason: InstallSucceeded - status: "True" - type: Released - helmChart: redpanda/redpanda-decommission - lastAppliedRevision: 5.7.9 - lastAttemptedRevision: 5.7.9 ---- apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: diff --git a/operator/tests/e2e-v2/decommission/00-create-redpanda.yaml b/operator/tests/e2e-v2/decommission/00-create-redpanda.yaml index 7990e6554..f46648374 100644 --- a/operator/tests/e2e-v2/decommission/00-create-redpanda.yaml +++ b/operator/tests/e2e-v2/decommission/00-create-redpanda.yaml @@ -4,8 +4,6 @@ kind: Redpanda metadata: name: decommission spec: - chartRef: - chartVersion: "5.7.9" clusterSpec: statefulset: replicas: 5 diff --git a/operator/tests/e2e-v2/decommission/01-assert-scale-down-redpanda.yaml b/operator/tests/e2e-v2/decommission/01-assert-scale-down-redpanda.yaml index e15f7d69a..2e6e84808 100644 --- a/operator/tests/e2e-v2/decommission/01-assert-scale-down-redpanda.yaml +++ b/operator/tests/e2e-v2/decommission/01-assert-scale-down-redpanda.yaml @@ -32,22 +32,6 @@ status: replicas: 4 updatedReplicas: 4 --- -apiVersion: helm.toolkit.fluxcd.io/v2beta2 -kind: HelmRelease -metadata: - name: decommission -status: - conditions: - - reason: UpgradeSucceeded - status: "True" - type: Ready - - reason: UpgradeSucceeded - status: "True" - type: Released - helmChart: redpanda/redpanda-decommission - lastAppliedRevision: 5.7.9 - lastAttemptedRevision: 5.7.9 ---- apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: diff --git a/operator/tests/e2e-v2/decommission/01-scale-down-redpanda.yaml b/operator/tests/e2e-v2/decommission/01-scale-down-redpanda.yaml index bff205c64..ef4a20970 100644 --- a/operator/tests/e2e-v2/decommission/01-scale-down-redpanda.yaml +++ b/operator/tests/e2e-v2/decommission/01-scale-down-redpanda.yaml @@ -4,8 +4,6 @@ kind: Redpanda metadata: name: decommission spec: - chartRef: - chartVersion: "5.7.9" clusterSpec: statefulset: replicas: 4 diff --git a/operator/tests/e2e-v2/decommission/02-assert-scale-down-redpanda.yaml b/operator/tests/e2e-v2/decommission/02-assert-scale-down-redpanda.yaml index fa5bec7e6..10cd20601 100644 --- a/operator/tests/e2e-v2/decommission/02-assert-scale-down-redpanda.yaml +++ b/operator/tests/e2e-v2/decommission/02-assert-scale-down-redpanda.yaml @@ -32,22 +32,6 @@ status: replicas: 3 updatedReplicas: 3 --- -apiVersion: helm.toolkit.fluxcd.io/v2beta2 -kind: HelmRelease -metadata: - name: decommission -status: - conditions: - - reason: UpgradeSucceeded - status: "True" - type: Ready - - reason: UpgradeSucceeded - status: "True" - type: Released - helmChart: redpanda/redpanda-decommission - lastAppliedRevision: 5.7.9 - lastAttemptedRevision: 5.7.9 ---- apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: diff --git a/operator/tests/e2e-v2/decommission/02-scale-down-redpanda.yaml b/operator/tests/e2e-v2/decommission/02-scale-down-redpanda.yaml index 4e2da9836..67ee9f3a4 100644 --- a/operator/tests/e2e-v2/decommission/02-scale-down-redpanda.yaml +++ b/operator/tests/e2e-v2/decommission/02-scale-down-redpanda.yaml @@ -4,8 +4,6 @@ kind: Redpanda metadata: name: decommission spec: - chartRef: - chartVersion: "5.7.9" clusterSpec: statefulset: replicas: 3 diff --git a/operator/tests/e2e-v2/node-deleted/00-assert-create-redpanda.yaml b/operator/tests/e2e-v2/node-deleted/00-assert-create-redpanda.yaml index 129df5f6c..6f7945829 100644 --- a/operator/tests/e2e-v2/node-deleted/00-assert-create-redpanda.yaml +++ b/operator/tests/e2e-v2/node-deleted/00-assert-create-redpanda.yaml @@ -34,22 +34,6 @@ status: replicas: 3 updatedReplicas: 3 --- -apiVersion: helm.toolkit.fluxcd.io/v2beta2 -kind: HelmRelease -metadata: - name: redpanda-node-deleted -status: - conditions: - - reason: InstallSucceeded - status: "True" - type: Ready - - reason: InstallSucceeded - status: "True" - type: Released - helmChart: redpanda/redpanda-redpanda-node-deleted - lastAppliedRevision: 5.3.2 - lastAttemptedRevision: 5.3.2 ---- apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: diff --git a/operator/tests/e2e-v2/node-deleted/00-create-redpanda.yaml b/operator/tests/e2e-v2/node-deleted/00-create-redpanda.yaml index a4f272602..1b1f026bd 100644 --- a/operator/tests/e2e-v2/node-deleted/00-create-redpanda.yaml +++ b/operator/tests/e2e-v2/node-deleted/00-create-redpanda.yaml @@ -4,8 +4,6 @@ kind: Redpanda metadata: name: redpanda-node-deleted spec: - chartRef: - chartVersion: "5.3.2" clusterSpec: statefulset: replicas: 3 diff --git a/operator/tests/e2e-v2/resource-redpanda-crud/00-assert-create-redpanda.yaml b/operator/tests/e2e-v2/resource-redpanda-crud/00-assert-create-redpanda.yaml index 68f6b20b5..b8f261729 100644 --- a/operator/tests/e2e-v2/resource-redpanda-crud/00-assert-create-redpanda.yaml +++ b/operator/tests/e2e-v2/resource-redpanda-crud/00-assert-create-redpanda.yaml @@ -6,8 +6,6 @@ metadata: - operator.redpanda.com/finalizer name: redpanda spec: - chartRef: - chartVersion: "5.3.2" clusterSpec: statefulset: replicas: 1 diff --git a/operator/tests/e2e-v2/resource-redpanda-crud/00-create-redpanda.yaml b/operator/tests/e2e-v2/resource-redpanda-crud/00-create-redpanda.yaml index f42a0d1f0..097975807 100644 --- a/operator/tests/e2e-v2/resource-redpanda-crud/00-create-redpanda.yaml +++ b/operator/tests/e2e-v2/resource-redpanda-crud/00-create-redpanda.yaml @@ -4,8 +4,6 @@ kind: Redpanda metadata: name: redpanda spec: - chartRef: - chartVersion: "5.3.2" clusterSpec: statefulset: replicas: 1 diff --git a/operator/tests/e2e-v2/resource-redpanda-crud/01-assert-update-chart-version.yaml b/operator/tests/e2e-v2/resource-redpanda-crud/01-assert-update-chart-version.yaml index 554ae7c3a..f35046d13 100644 --- a/operator/tests/e2e-v2/resource-redpanda-crud/01-assert-update-chart-version.yaml +++ b/operator/tests/e2e-v2/resource-redpanda-crud/01-assert-update-chart-version.yaml @@ -6,8 +6,6 @@ metadata: - operator.redpanda.com/finalizer name: redpanda spec: - chartRef: - chartVersion: "5.5.1" clusterSpec: statefulset: replicas: 1 diff --git a/operator/tests/e2e-v2/resource-redpanda-crud/01-update-chart-version.yaml b/operator/tests/e2e-v2/resource-redpanda-crud/01-update-chart-version.yaml index 778b2efc6..87c63d0ef 100644 --- a/operator/tests/e2e-v2/resource-redpanda-crud/01-update-chart-version.yaml +++ b/operator/tests/e2e-v2/resource-redpanda-crud/01-update-chart-version.yaml @@ -5,4 +5,4 @@ metadata: name: redpanda spec: chartRef: - chartVersion: "5.5.1" + useFlux: false diff --git a/operator/tests/e2e-v2/resource-redpanda-crud/02-assert-update-clusterspec.yaml b/operator/tests/e2e-v2/resource-redpanda-crud/02-assert-update-clusterspec.yaml index d9e1f47d8..029d128fb 100644 --- a/operator/tests/e2e-v2/resource-redpanda-crud/02-assert-update-clusterspec.yaml +++ b/operator/tests/e2e-v2/resource-redpanda-crud/02-assert-update-clusterspec.yaml @@ -6,8 +6,6 @@ metadata: - operator.redpanda.com/finalizer name: redpanda spec: - chartRef: - chartVersion: "5.5.1" clusterSpec: statefulset: replicas: 3 diff --git a/operator/tests/e2e-v2/resource-redpanda-crud/02-update-clusterspec.yaml b/operator/tests/e2e-v2/resource-redpanda-crud/02-update-clusterspec.yaml index b9594c995..a5486a4d9 100644 --- a/operator/tests/e2e-v2/resource-redpanda-crud/02-update-clusterspec.yaml +++ b/operator/tests/e2e-v2/resource-redpanda-crud/02-update-clusterspec.yaml @@ -6,8 +6,6 @@ metadata: - operator.redpanda.com/finalizer name: redpanda spec: - chartRef: - chartVersion: "5.5.1" clusterSpec: statefulset: replicas: 3 diff --git a/operator/tests/e2e-v2/resource-topic-crud/00-create-redpanda.yaml b/operator/tests/e2e-v2/resource-topic-crud/00-create-redpanda.yaml index 36012cb5f..c81938565 100644 --- a/operator/tests/e2e-v2/resource-topic-crud/00-create-redpanda.yaml +++ b/operator/tests/e2e-v2/resource-topic-crud/00-create-redpanda.yaml @@ -4,8 +4,6 @@ kind: Redpanda metadata: name: redpanda-topic spec: - chartRef: - chartVersion: "5.3.3" clusterSpec: statefulset: replicas: 3 diff --git a/operator/tests/e2e-v2/upgrade-values-check/00-assert-create-redpanda.yaml b/operator/tests/e2e-v2/upgrade-values-check/00-assert-create-redpanda.yaml index 5630155e7..47a641f36 100644 --- a/operator/tests/e2e-v2/upgrade-values-check/00-assert-create-redpanda.yaml +++ b/operator/tests/e2e-v2/upgrade-values-check/00-assert-create-redpanda.yaml @@ -32,25 +32,6 @@ status: replicas: 1 updatedReplicas: 1 --- -apiVersion: helm.toolkit.fluxcd.io/v2beta2 -kind: HelmRelease -metadata: - name: redpanda-values-check -status: - conditions: - - reason: InstallSucceeded - status: "True" - type: Ready - - reason: InstallSucceeded - status: "True" - type: Released - helmChart: redpanda/redpanda-redpanda-values-check - lastAppliedRevision: 5.3.2 - lastAttemptedRevision: 5.3.2 - lastAttemptedConfigDigest: sha256:bd42835737f3bc042176268bda36420d9edab32547c60c778cb6835c13e117d6 - lastAttemptedGeneration: 1 - observedGeneration: 1 ---- apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: diff --git a/operator/tests/e2e-v2/upgrade-values-check/00-create-redpanda.yaml b/operator/tests/e2e-v2/upgrade-values-check/00-create-redpanda.yaml index 0f1632d31..7e85294ac 100644 --- a/operator/tests/e2e-v2/upgrade-values-check/00-create-redpanda.yaml +++ b/operator/tests/e2e-v2/upgrade-values-check/00-create-redpanda.yaml @@ -4,8 +4,6 @@ kind: Redpanda metadata: name: redpanda-values-check spec: - chartRef: - chartVersion: "5.3.2" clusterSpec: statefulset: replicas: 1 diff --git a/operator/tests/e2e-v2/upgrade-values-check/01-assert-upgrade-redpanda.yaml b/operator/tests/e2e-v2/upgrade-values-check/01-assert-upgrade-redpanda.yaml index 86aaa50a9..5d8c5986f 100644 --- a/operator/tests/e2e-v2/upgrade-values-check/01-assert-upgrade-redpanda.yaml +++ b/operator/tests/e2e-v2/upgrade-values-check/01-assert-upgrade-redpanda.yaml @@ -32,25 +32,6 @@ status: replicas: 1 updatedReplicas: 1 --- -apiVersion: helm.toolkit.fluxcd.io/v2beta2 -kind: HelmRelease -metadata: - name: redpanda-values-check -status: - conditions: - - reason: UpgradeSucceeded - status: "True" - type: Ready - - reason: UpgradeSucceeded - status: "True" - type: Released - helmChart: redpanda/redpanda-redpanda-values-check - lastAppliedRevision: 5.3.2 - lastAttemptedRevision: 5.3.2 - lastAttemptedConfigDigest: sha256:2ba5060a47f2ee629adb0bcd117f4b6d66127e26956d417e7e4e076456c2f8f8 - lastAttemptedGeneration: 2 - observedGeneration: 2 ---- apiVersion: kuttl.dev/v1beta1 kind: TestAssert collectors: