From 57325adafda6fd991e03b3fe9adbcb1d3e72eeaa Mon Sep 17 00:00:00 2001 From: Pankti Shah Date: Wed, 25 Oct 2023 10:03:27 -0700 Subject: [PATCH] Remove experimentalSelfManagedUpgrade flag for management cluster reconciler --- controllers/cluster_controller.go | 22 +---------- controllers/cluster_controller_test.go | 55 ++------------------------ 2 files changed, 5 insertions(+), 72 deletions(-) diff --git a/controllers/cluster_controller.go b/controllers/cluster_controller.go index ffeae8a4f0f9..c99ebc47012b 100644 --- a/controllers/cluster_controller.go +++ b/controllers/cluster_controller.go @@ -50,13 +50,6 @@ type ClusterReconciler struct { clusterValidator ClusterValidator packagesClient PackagesClient machineHealthCheck MachineHealthCheckReconciler - - // experimentalSelfManagedUpgrade enables management cluster full upgrades. - // The default behavior for management cluster only reconciles the worker nodes. - // When this is enabled, the controller will handle management clusters in the same - // way as workload clusters: it will reconcile CP, etcd and workers. - // Only intended for internal testing. - experimentalSelfManagedUpgrade bool } // PackagesClient handles curated packages operations from within the cluster @@ -109,14 +102,6 @@ func NewClusterReconciler(client client.Client, registry ProviderClusterReconcil return c } -// WithExperimentalSelfManagedClusterUpgrades allows to enable experimental upgrades for self -// managed clusters. -func WithExperimentalSelfManagedClusterUpgrades(exp bool) ClusterReconcilerOption { - return func(c *ClusterReconciler) { - c.experimentalSelfManagedUpgrade = exp - } -} - // SetupWithManager sets up the controller with the Manager. func (r *ClusterReconciler) SetupWithManager(mgr ctrl.Manager, log logr.Logger) error { childObjectHandler := handlers.ChildObjectToClusters(log) @@ -322,12 +307,7 @@ func (r *ClusterReconciler) reconcile(ctx context.Context, log logr.Logger, clus return reconcileResult.ToCtrlResult(), nil } - if cluster.IsSelfManaged() && !r.experimentalSelfManagedUpgrade { - // self-managed clusters should only reconcile worker nodes to avoid control plane instability - reconcileResult, err = clusterProviderReconciler.ReconcileWorkerNodes(ctx, log, cluster) - } else { - reconcileResult, err = clusterProviderReconciler.Reconcile(ctx, log, cluster) - } + reconcileResult, err = clusterProviderReconciler.Reconcile(ctx, log, cluster) if err != nil { return ctrl.Result{}, err diff --git a/controllers/cluster_controller_test.go b/controllers/cluster_controller_test.go index 8cddf26eced4..f541a62771e1 100644 --- a/controllers/cluster_controller_test.go +++ b/controllers/cluster_controller_test.go @@ -182,7 +182,7 @@ func TestClusterReconcilerReconcileSelfManagedCluster(t *testing.T) { registry := newRegistryMock(providerReconciler) c := fake.NewClientBuilder().WithRuntimeObjects(selfManagedCluster, kcp).Build() mockPkgs := mocks.NewMockPackagesClient(controller) - providerReconciler.EXPECT().ReconcileWorkerNodes(ctx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(selfManagedCluster)) + providerReconciler.EXPECT().Reconcile(ctx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(selfManagedCluster)) mhcReconciler.EXPECT().Reconcile(ctx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(selfManagedCluster)).Return(nil) r := controllers.NewClusterReconciler(c, registry, iam, clusterValidator, mockPkgs, mhcReconciler) @@ -622,7 +622,7 @@ func TestClusterReconcilerReconcileSelfManagedClusterConditions(t *testing.T) { iam.EXPECT().EnsureCASecret(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Return(controller.Result{}, nil) iam.EXPECT().Reconcile(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Return(controller.Result{}, nil) - providerReconciler.EXPECT().ReconcileWorkerNodes(gomock.Any(), gomock.Any(), gomock.Any()).Times(1) + providerReconciler.EXPECT().Reconcile(gomock.Any(), gomock.Any(), gomock.Any()).Times(1) mhcReconciler.EXPECT().Reconcile(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Return(nil) r := controllers.NewClusterReconciler(testClient, registry, iam, clusterValidator, mockPkgs, mhcReconciler) @@ -774,11 +774,11 @@ func TestClusterReconcilerReconcileGenerations(t *testing.T) { if tt.wantReconciliation { iam.EXPECT().EnsureCASecret(ctx, gomock.AssignableToTypeOf(logr.Logger{}), gomock.AssignableToTypeOf(config.Cluster)).Return(controller.Result{}, nil) iam.EXPECT().Reconcile(ctx, gomock.AssignableToTypeOf(logr.Logger{}), gomock.AssignableToTypeOf(config.Cluster)).Return(controller.Result{}, nil) - providerReconciler.EXPECT().ReconcileWorkerNodes(ctx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Times(1) + providerReconciler.EXPECT().Reconcile(ctx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Times(1) mhcReconciler.EXPECT().Reconcile(ctx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Return(nil) } else { - providerReconciler.EXPECT().ReconcileWorkerNodes(gomock.Any(), gomock.Any(), gomock.Any()).Times(0) + providerReconciler.EXPECT().Reconcile(gomock.Any(), gomock.Any(), gomock.Any()).Times(0) } r := controllers.NewClusterReconciler(client, registry, iam, clusterValidator, mockPkgs, mhcReconciler) @@ -802,53 +802,6 @@ func TestClusterReconcilerReconcileGenerations(t *testing.T) { } } -func TestClusterReconcilerReconcileSelfManagedClusterWithExperimentalUpgrades(t *testing.T) { - g := NewWithT(t) - ctx := context.Background() - version := test.DevEksaVersion() - - selfManagedCluster := &anywherev1.Cluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: "my-management-cluster", - }, - Spec: anywherev1.ClusterSpec{ - BundlesRef: &anywherev1.BundlesRef{ - Name: "my-bundles-ref", - }, - EksaVersion: &version, - ClusterNetwork: anywherev1.ClusterNetwork{ - CNIConfig: &anywherev1.CNIConfig{ - Cilium: &anywherev1.CiliumConfig{}, - }, - }, - }, - Status: anywherev1.ClusterStatus{ - ReconciledGeneration: 1, - }, - } - - kcp := testKubeadmControlPlaneFromCluster(selfManagedCluster) - - controller := gomock.NewController(t) - providerReconciler := mocks.NewMockProviderClusterReconciler(controller) - iam := mocks.NewMockAWSIamConfigReconciler(controller) - clusterValidator := mocks.NewMockClusterValidator(controller) - registry := newRegistryMock(providerReconciler) - c := fake.NewClientBuilder().WithRuntimeObjects(selfManagedCluster, kcp).Build() - mockPkgs := mocks.NewMockPackagesClient(controller) - mhcReconciler := mocks.NewMockMachineHealthCheckReconciler(controller) - - providerReconciler.EXPECT().Reconcile(ctx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(selfManagedCluster)) - mhcReconciler.EXPECT().Reconcile(ctx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(selfManagedCluster)).Return(nil) - - r := controllers.NewClusterReconciler(c, registry, iam, clusterValidator, mockPkgs, mhcReconciler, - controllers.WithExperimentalSelfManagedClusterUpgrades(true), - ) - result, err := r.Reconcile(ctx, clusterRequest(selfManagedCluster)) - g.Expect(err).ToNot(HaveOccurred()) - g.Expect(result).To(Equal(ctrl.Result{})) -} - func TestClusterReconcilerReconcilePausedCluster(t *testing.T) { g := NewWithT(t) ctx := context.Background()