From 9386064bec6e53e358a24811c1bfe051f5265231 Mon Sep 17 00:00:00 2001 From: m00g3n Date: Tue, 9 Jul 2024 12:07:50 +0200 Subject: [PATCH 1/2] change delete Runtime CR to wait on Shoot CR delete --- ...ucturemanager.kyma-project.io_runtimes.yaml | 9 +++++++-- .../runtime/fsm/runtime_fsm_common.go | 4 ++++ .../runtime/fsm/runtime_fsm_initialise.go | 18 ++++++++++++++---- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/config/crd/bases/infrastructuremanager.kyma-project.io_runtimes.yaml b/config/crd/bases/infrastructuremanager.kyma-project.io_runtimes.yaml index 8bd0bb71..29e2da1f 100644 --- a/config/crd/bases/infrastructuremanager.kyma-project.io_runtimes.yaml +++ b/config/crd/bases/infrastructuremanager.kyma-project.io_runtimes.yaml @@ -758,14 +758,19 @@ spec: >= v1.26.' type: string systemReserved: - description: SystemReserved is the configuration + description: 'SystemReserved is the configuration for resources reserved for system processes not managed by kubernetes (e.g. journald). When updating these values, be aware that cgroup resizes may not succeed on active worker nodes. Look for the NodeAllocatableEnforced event to determine if the configuration was - applied. + applied. Deprecated: Separately configuring + resource reservations for system processes + is deprecated in Gardener and will be removed + soon. Please merge existing resource reservations + into the kubeReserved field. TODO(MichaelEischer): + Drop this field after v1.113 has been released.' properties: cpu: anyOf: diff --git a/internal/controller/runtime/fsm/runtime_fsm_common.go b/internal/controller/runtime/fsm/runtime_fsm_common.go index b28a109e..5ba47706 100644 --- a/internal/controller/runtime/fsm/runtime_fsm_common.go +++ b/internal/controller/runtime/fsm/runtime_fsm_common.go @@ -28,6 +28,10 @@ func requeue() (stateFn, *ctrl.Result, error) { return nil, &ctrl.Result{Requeue: true}, nil } +func requeueAfter(d time.Duration) (stateFn, *ctrl.Result, error) { + return nil, &ctrl.Result{RequeueAfter: d}, nil +} + func stop() (stateFn, *ctrl.Result, error) { return nil, nil, nil } diff --git a/internal/controller/runtime/fsm/runtime_fsm_initialise.go b/internal/controller/runtime/fsm/runtime_fsm_initialise.go index 9a37a186..b5b1cfde 100644 --- a/internal/controller/runtime/fsm/runtime_fsm_initialise.go +++ b/internal/controller/runtime/fsm/runtime_fsm_initialise.go @@ -2,6 +2,7 @@ package fsm import ( "context" + "time" imv1 "github.com/kyma-project/infrastructure-manager/api/v1" "k8s.io/apimachinery/pkg/api/meta" @@ -42,15 +43,24 @@ func sFnInitialize(ctx context.Context, m *fsm, s *systemState) (stateFn, *ctrl. return switchState(sFnPrepareCluster) // wait for pending shoot operation to complete } - shootInOrAfterDeleting := s.shoot == nil || !s.shoot.GetDeletionTimestamp().IsZero() + // resource cleanup is done; + // instance is being deleted and shoot was already deleted + if !instanceIsNotBeingDeleted && instanceHasFinalizer && s.shoot == nil { + return removeFinalizerAndStop(ctx, m, s) + } - if !instanceIsNotBeingDeleted && instanceHasFinalizer && !shootInOrAfterDeleting { + // resource cleanup did not start; + // instance is being deleted and shoot is not being deleted + if !instanceIsNotBeingDeleted && instanceHasFinalizer && s.shoot.DeletionTimestamp.IsZero() { m.log.Info("Delete instance resources") return switchState(sFnDeleteShoot) } - if !instanceIsNotBeingDeleted && instanceHasFinalizer && shootInOrAfterDeleting { - return removeFinalizerAndStop(ctx, m, s) + // resource cleanup in progress; + // instance is being deleted and shoot is being deleted + if !instanceIsNotBeingDeleted && instanceHasFinalizer { + m.log.Info("Waiting on instance resources being deleted") + return requeueAfter(15 * time.Second) } m.log.Info("noting to reconcile, stopping sfm") From de5eb82aa6a130fe788fab424b19b21d26f6dcce Mon Sep 17 00:00:00 2001 From: m00g3n Date: Tue, 9 Jul 2024 13:01:46 +0200 Subject: [PATCH 2/2] fix linter issues --- internal/controller/runtime/fsm/runtime_fsm_initialise.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/controller/runtime/fsm/runtime_fsm_initialise.go b/internal/controller/runtime/fsm/runtime_fsm_initialise.go index b5b1cfde..ea1330de 100644 --- a/internal/controller/runtime/fsm/runtime_fsm_initialise.go +++ b/internal/controller/runtime/fsm/runtime_fsm_initialise.go @@ -2,7 +2,6 @@ package fsm import ( "context" - "time" imv1 "github.com/kyma-project/infrastructure-manager/api/v1" "k8s.io/apimachinery/pkg/api/meta" @@ -60,7 +59,7 @@ func sFnInitialize(ctx context.Context, m *fsm, s *systemState) (stateFn, *ctrl. // instance is being deleted and shoot is being deleted if !instanceIsNotBeingDeleted && instanceHasFinalizer { m.log.Info("Waiting on instance resources being deleted") - return requeueAfter(15 * time.Second) + return requeueAfter(gardenerRequeueDuration) } m.log.Info("noting to reconcile, stopping sfm")