diff --git a/cmd/main.go b/cmd/main.go index 8e26be57..429329c5 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -69,18 +69,17 @@ func init() { // Default values for the Runtime controller configuration const ( - defaultControlPlaneRequeueDuration = 10 * time.Second - defaultRuntimeCtrlGardenerRequestTimeout = 1 * time.Second - defaultRuntimeCtrlGardenerRateLimiterQps = 5 - defaultRuntimeCtrlGardenerRateLimiterBurst = 5 -) - -// Default values for the Gardener Cluster controller configuration -const ( + defaultControlPlaneRequeueDuration = 10 * time.Second + defaultGardenerRequestTimeout = 3 * time.Second + defaultGardenerRateLimiterQps = 5 + defaultGardenerRateLimiterBurst = 5 defaultMinimalRotationTimeRatio = 0.6 defaultExpirationTime = 24 * time.Hour defaultGardenerReconciliationTimeout = 60 * time.Second defaultGardenerRequeueDuration = 15 * time.Second + defaultShootCreateRequeueDuration = 60 * time.Second + defaultShootDeleteRequeueDuration = 90 * time.Second + defaultShootReconcileRequeueDuration = 30 * time.Second ) func main() { @@ -109,9 +108,9 @@ func main() { flag.Float64Var(&minimalRotationTimeRatio, "minimal-rotation-time", defaultMinimalRotationTimeRatio, "The ratio determines what is the minimal time that needs to pass to rotate certificate.") flag.DurationVar(&expirationTime, "kubeconfig-expiration-time", defaultExpirationTime, "Dynamic kubeconfig expiration time") flag.DurationVar(&gardenerCtrlReconciliationTimeout, "gardener-ctrl-reconcilation-timeout", defaultGardenerReconciliationTimeout, "Timeout duration for reconlication for Gardener Cluster Controller") - flag.DurationVar(&runtimeCtrlGardenerRequestTimeout, "runtime-ctrl-gardener-request-timeout", defaultRuntimeCtrlGardenerRequestTimeout, "Timeout duration for Gardener client for Runtime Controller") - flag.IntVar(&runtimeCtrlGardenerRateLimiterQps, "runtime-ctrl-gardener-ratelimiter-qps", defaultRuntimeCtrlGardenerRateLimiterQps, "Gardener client rate limiter QPS for Runtime Controller") - flag.IntVar(&runtimeCtrlGardenerRateLimiterBurst, "runtime-ctrl-gardener-ratelimiter-burst", defaultRuntimeCtrlGardenerRateLimiterBurst, "Gardener client rate limiter burst for Runtime Controller") + flag.DurationVar(&runtimeCtrlGardenerRequestTimeout, "gardener-request-timeout", defaultGardenerRequestTimeout, "Timeout duration for Gardener client for Runtime Controller") + flag.IntVar(&runtimeCtrlGardenerRateLimiterQps, "gardener-ratelimiter-qps", defaultGardenerRateLimiterQps, "Gardener client rate limiter QPS for Runtime Controller") + flag.IntVar(&runtimeCtrlGardenerRateLimiterBurst, "gardener-ratelimiter-burst", defaultGardenerRateLimiterBurst, "Gardener client rate limiter burst for Runtime Controller") flag.StringVar(&converterConfigFilepath, "converter-config-filepath", "/converter-config/converter_config.json", "A file path to the gardener shoot converter configuration.") flag.BoolVar(&shootSpecDumpEnabled, "shoot-spec-dump-enabled", false, "Feature flag to allow persisting specs of created shoots") flag.BoolVar(&auditLogMandatory, "audit-log-mandatory", true, "Feature flag to enable strict mode for audit log configuration") @@ -205,14 +204,17 @@ func main() { } cfg := fsm.RCCfg{ - GardenerRequeueDuration: defaultGardenerRequeueDuration, - ControlPlaneRequeueDuration: defaultControlPlaneRequeueDuration, - Finalizer: infrastructuremanagerv1.Finalizer, - ShootNamesapace: gardenerNamespace, - Config: config, - AuditLogMandatory: auditLogMandatory, - Metrics: metrics, - AuditLogging: auditLogDataMap, + GardenerRequeueDuration: defaultGardenerRequeueDuration, + RequeueDurationShootCreate: defaultShootCreateRequeueDuration, + RequeueDurationShootDelete: defaultShootDeleteRequeueDuration, + RequeueDurationShootReconcile: defaultShootReconcileRequeueDuration, + ControlPlaneRequeueDuration: defaultControlPlaneRequeueDuration, + Finalizer: infrastructuremanagerv1.Finalizer, + ShootNamesapace: gardenerNamespace, + Config: config, + AuditLogMandatory: auditLogMandatory, + Metrics: metrics, + AuditLogging: auditLogDataMap, } if shootSpecDumpEnabled { cfg.PVCPath = "/testdata/kim" diff --git a/internal/controller/runtime/fsm/runtime_fsm.go b/internal/controller/runtime/fsm/runtime_fsm.go index 0a5391d1..5d79d549 100644 --- a/internal/controller/runtime/fsm/runtime_fsm.go +++ b/internal/controller/runtime/fsm/runtime_fsm.go @@ -26,14 +26,17 @@ type writerGetter = func(filePath string) (io.Writer, error) // runtime reconciler specific configuration type RCCfg struct { - GardenerRequeueDuration time.Duration - ControlPlaneRequeueDuration time.Duration - Finalizer string - PVCPath string - ShootNamesapace string - AuditLogMandatory bool - Metrics metrics.Metrics - AuditLogging auditlogs.Configuration + GardenerRequeueDuration time.Duration + RequeueDurationShootCreate time.Duration + RequeueDurationShootDelete time.Duration + RequeueDurationShootReconcile time.Duration + ControlPlaneRequeueDuration time.Duration + Finalizer string + PVCPath string + ShootNamesapace string + AuditLogMandatory bool + Metrics metrics.Metrics + AuditLogging auditlogs.Configuration config.Config } diff --git a/internal/controller/runtime/fsm/runtime_fsm_delete_shoot.go b/internal/controller/runtime/fsm/runtime_fsm_delete_shoot.go index c94ab734..2cdfe46d 100644 --- a/internal/controller/runtime/fsm/runtime_fsm_delete_shoot.go +++ b/internal/controller/runtime/fsm/runtime_fsm_delete_shoot.go @@ -2,8 +2,6 @@ package fsm import ( "context" - "time" - gardener "github.com/gardener/gardener/pkg/apis/core/v1beta1" imv1 "github.com/kyma-project/infrastructure-manager/api/v1" "k8s.io/utils/ptr" @@ -11,17 +9,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) -const ( - deletionRequeueTime = 2 * time.Minute -) - func sFnDeleteShoot(ctx context.Context, m *fsm, s *systemState) (stateFn, *ctrl.Result, error) { m.log.Info("delete shoot state") // wait section if !s.shoot.GetDeletionTimestamp().IsZero() { m.log.Info("Waiting for shoot to be deleted", "Name", s.shoot.Name, "Namespace", s.shoot.Namespace) - return requeueAfter(deletionRequeueTime) + return requeueAfter(m.RCCfg.RequeueDurationShootDelete) } // action section @@ -63,7 +57,7 @@ func sFnDeleteShoot(ctx context.Context, m *fsm, s *systemState) (stateFn, *ctrl } // out section - return updateStatusAndRequeueAfter(deletionRequeueTime) + return updateStatusAndRequeueAfter(m.RCCfg.RequeueDurationShootDelete) } // workaround diff --git a/internal/controller/runtime/fsm/runtime_fsm_waiting_for_shoot_reconcile.go b/internal/controller/runtime/fsm/runtime_fsm_waiting_for_shoot_reconcile.go index 788e60d1..1b6f2855 100644 --- a/internal/controller/runtime/fsm/runtime_fsm_waiting_for_shoot_reconcile.go +++ b/internal/controller/runtime/fsm/runtime_fsm_waiting_for_shoot_reconcile.go @@ -23,7 +23,7 @@ func sFnWaitForShootReconcile(_ context.Context, m *fsm, s *systemState) (stateF "Unknown", "Shoot update is in progress") - return updateStatusAndRequeueAfter(m.RCCfg.GardenerRequeueDuration) + return updateStatusAndRequeueAfter(m.RCCfg.RequeueDurationShootReconcile) case gardener.LastOperationStateFailed: lastErrors := s.shoot.Status.LastErrors @@ -36,7 +36,7 @@ func sFnWaitForShootReconcile(_ context.Context, m *fsm, s *systemState) (stateF imv1.ConditionReasonShootCreationPending, "Unknown", "Retryable gardener errors during cluster reconcile") - return updateStatusAndRequeueAfter(m.RCCfg.GardenerRequeueDuration) + return updateStatusAndRequeueAfter(m.RCCfg.RequeueDurationShootReconcile) } msg := fmt.Sprintf("error during cluster processing: reconcilation failed for shoot %s, reason: %s, exiting with no retry", s.shoot.Name, reason) diff --git a/internal/controller/runtime/fsm/runtime_fsm_waiting_shoot_creation.go b/internal/controller/runtime/fsm/runtime_fsm_waiting_shoot_creation.go index 2c0036fc..d0322379 100644 --- a/internal/controller/runtime/fsm/runtime_fsm_waiting_shoot_creation.go +++ b/internal/controller/runtime/fsm/runtime_fsm_waiting_shoot_creation.go @@ -39,7 +39,7 @@ func sFnWaitForShootCreation(_ context.Context, m *fsm, s *systemState) (stateFn "Unknown", "Shoot creation in progress") - return updateStatusAndRequeueAfter(m.RCCfg.GardenerRequeueDuration) + return updateStatusAndRequeueAfter(m.RCCfg.RequeueDurationShootCreate) case gardener.LastOperationStateFailed: lastErrors := s.shoot.Status.LastErrors @@ -52,7 +52,7 @@ func sFnWaitForShootCreation(_ context.Context, m *fsm, s *systemState) (stateFn imv1.ConditionReasonShootCreationPending, "Unknown", "Retryable gardener errors during cluster provisioning") - return updateStatusAndRequeueAfter(m.RCCfg.GardenerRequeueDuration) + return updateStatusAndRequeueAfter(m.RCCfg.RequeueDurationShootCreate) } msg := fmt.Sprintf("Provisioning failed for shoot: %s ! Last state: %s, Description: %s", s.shoot.Name, s.shoot.Status.LastOperation.State, s.shoot.Status.LastOperation.Description) diff --git a/internal/controller/runtime/fsm/utilz_for_test.go b/internal/controller/runtime/fsm/utilz_for_test.go index f5134dd7..d0c8801c 100644 --- a/internal/controller/runtime/fsm/utilz_for_test.go +++ b/internal/controller/runtime/fsm/utilz_for_test.go @@ -24,6 +24,8 @@ type fakeFSMOpt func(*fsm) error const defaultControlPlaneRequeueDuration = 10 * time.Second const defaultGardenerRequeueDuration = 15 * time.Second +const defaultRequeueDurationShootCreate = 15 * time.Second +const defaultRequeueDurationShootDelete = 15 * time.Second var ( errFailedToCreateFakeFSM = fmt.Errorf("failed to create fake FSM") diff --git a/internal/controller/runtime/runtime_controller.go b/internal/controller/runtime/runtime_controller.go index ed2dc768..ea65147f 100644 --- a/internal/controller/runtime/runtime_controller.go +++ b/internal/controller/runtime/runtime_controller.go @@ -51,6 +51,8 @@ var requCounter = 0 // nolint:gochecknoglobals func (r *RuntimeReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.Result, error) { r.Log.Info(request.String()) + // n\] + var runtime imv1.Runtime if err := r.Get(ctx, request.NamespacedName, &runtime); err != nil { return ctrl.Result{ diff --git a/internal/controller/runtime/suite_test.go b/internal/controller/runtime/suite_test.go index 473b8948..8eb94681 100644 --- a/internal/controller/runtime/suite_test.go +++ b/internal/controller/runtime/suite_test.go @@ -121,12 +121,15 @@ var _ = BeforeSuite(func() { mm.On("CleanUpRuntimeGauge", mock.Anything, mock.Anything).Return() fsmCfg := fsm.RCCfg{ - Finalizer: imv1.Finalizer, - Config: convConfig, - Metrics: mm, - AuditLogging: map[string]map[string]auditlogs.AuditLogData{}, - GardenerRequeueDuration: 3 * time.Second, - ControlPlaneRequeueDuration: 3 * time.Second, + Finalizer: imv1.Finalizer, + Config: convConfig, + Metrics: mm, + AuditLogging: map[string]map[string]auditlogs.AuditLogData{}, + GardenerRequeueDuration: 3 * time.Second, + ControlPlaneRequeueDuration: 3 * time.Second, + RequeueDurationShootReconcile: 3 * time.Second, + RequeueDurationShootCreate: 3 * time.Second, + RequeueDurationShootDelete: 3 * time.Second, } runtimeReconciler = NewRuntimeReconciler(mgr, gardenerTestClient, logger, fsmCfg)