From 59a1df0d69ce8a1b3b70a6e1bdc044eef943fa8f Mon Sep 17 00:00:00 2001 From: Tanvir Tatla Date: Tue, 20 Feb 2024 11:41:39 -0800 Subject: [PATCH] Pause eksa cluster before moving capi for delete --- pkg/dependencies/factory.go | 2 +- pkg/workflows/management/delete_move_capi.go | 8 +++++++- pkg/workflows/management/delete_test.go | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/dependencies/factory.go b/pkg/dependencies/factory.go index 55fadf9ede53..24747360183e 100644 --- a/pkg/dependencies/factory.go +++ b/pkg/dependencies/factory.go @@ -1286,7 +1286,7 @@ func (f *Factory) WithClusterDeleter() *Factory { f.buildSteps = append(f.buildSteps, func(ctx context.Context) error { var opts []clustermanager.DeleterOpt if f.config.noTimeouts { - opts = append(opts, clustermanager.WithDeleterNoTimeouts()) + opts = append(opts, clustermanager.WithDeleterApplyClusterTimeout(time.Hour)) } f.dependencies.ClusterDeleter = clustermanager.NewDeleter( diff --git a/pkg/workflows/management/delete_move_capi.go b/pkg/workflows/management/delete_move_capi.go index 3cbe166952e8..d34a224dd6a9 100644 --- a/pkg/workflows/management/delete_move_capi.go +++ b/pkg/workflows/management/delete_move_capi.go @@ -12,8 +12,14 @@ import ( type moveClusterManagementForDeleteTask struct{} func (s *moveClusterManagementForDeleteTask) Run(ctx context.Context, commandContext *task.CommandContext) task.Task { + err := commandContext.ClusterManager.PauseEKSAControllerReconcile(ctx, commandContext.WorkloadCluster, commandContext.ClusterSpec, commandContext.Provider) + if err != nil { + commandContext.SetError(err) + return &workflows.CollectDiagnosticsTask{} + } + logger.Info("Moving cluster management from workload cluster to bootstrap") - err := commandContext.ClusterManager.MoveCAPI(ctx, commandContext.WorkloadCluster, commandContext.BootstrapCluster, commandContext.WorkloadCluster.Name, commandContext.ClusterSpec, types.WithNodeRef()) + err = commandContext.ClusterManager.MoveCAPI(ctx, commandContext.WorkloadCluster, commandContext.BootstrapCluster, commandContext.WorkloadCluster.Name, commandContext.ClusterSpec, types.WithNodeRef()) if err != nil { commandContext.SetError(err) return &workflows.CollectDiagnosticsTask{} diff --git a/pkg/workflows/management/delete_test.go b/pkg/workflows/management/delete_test.go index 0c6f1963ada0..5776f82e6ccf 100644 --- a/pkg/workflows/management/delete_test.go +++ b/pkg/workflows/management/delete_test.go @@ -159,6 +159,7 @@ func (c *deleteTestSetup) expectInstallCAPI(err error) { } func (c *deleteTestSetup) expectMoveCAPI(err error) { + c.clusterManager.EXPECT().PauseEKSAControllerReconcile(c.ctx, c.workloadCluster, c.clusterSpec, c.provider) c.clusterManager.EXPECT().MoveCAPI(c.ctx, c.workloadCluster, c.bootstrapCluster, c.workloadCluster.Name, c.clusterSpec, gomock.Any()).Return(err) }