From 202c1441bfe22afad0ddfe4c9fabc2375679e059 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Golicz?= Date: Sun, 4 Aug 2024 12:32:34 +0200 Subject: [PATCH] Adding timeouts to Runtime controller configuration --- cmd/main.go | 19 ++++++++++++++++--- .../controller/runtime/fsm/runtime_fsm.go | 11 +++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 9c7e7d86..8b62a627 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -62,6 +62,10 @@ const defaultExpirationTime = 24 * time.Hour const defaultRuntimeReconcilerEnabled = true const defaultGardenerRequestTimeout = 60 * time.Second +const defaultProvisioingTimeout = 15 * time.Minute +const defaultDeprovisioningTimeout = 15 * time.Minute +const defaultUpgradeTimeout = 15 * time.Minute + func main() { var metricsAddr string var enableLeaderElection bool @@ -74,6 +78,9 @@ func main() { var enableRuntimeReconciler bool var converterConfigFilepath string var shootSpecDumpEnabled bool + var provisionTimeout time.Duration + var deprovisionTimeout time.Duration + var upgradeTimeout time.Duration flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.") flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") @@ -88,6 +95,9 @@ func main() { flag.BoolVar(&enableRuntimeReconciler, "runtime-reconciler-enabled", defaultRuntimeReconcilerEnabled, "Feature flag for all runtime reconciler functionalities") flag.StringVar(&converterConfigFilepath, "converter-config-filepath", "hack/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.DurationVar(&provisionTimeout, "provisioning-timeout", defaultProvisioingTimeout, "Runtime provisioning timeout") + flag.DurationVar(&deprovisionTimeout, "deprovisioning-timeout", defaultDeprovisioningTimeout, "Runtime deprovisioning timeout") + flag.DurationVar(&upgradeTimeout, "kubeconfig-expiration-time", defaultUpgradeTimeout, "Runtime upgrade timeout") opts := zap.Options{ Development: true, @@ -170,9 +180,12 @@ func main() { } cfg := fsm.RCCfg{ - Finalizer: infrastructuremanagerv1.Finalizer, - ShootNamesapace: gardenerNamespace, - ConverterConfig: converterConfig, + Finalizer: infrastructuremanagerv1.Finalizer, + ShootNamesapace: gardenerNamespace, + ConverterConfig: converterConfig, + ProvisionTimeout: provisionTimeout, + DeprovisionTimeout: deprovisionTimeout, + UpdateTimeout: upgradeTimeout, } 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 f3ec2487..4f360477 100644 --- a/internal/controller/runtime/fsm/runtime_fsm.go +++ b/internal/controller/runtime/fsm/runtime_fsm.go @@ -29,9 +29,12 @@ type writerGetter = func(filePath string) (io.Writer, error) // runtime reconciler specific configuration type RCCfg struct { - Finalizer string - PVCPath string - ShootNamesapace string + ProvisionTimeout time.Duration + DeprovisionTimeout time.Duration + UpdateTimeout time.Duration + Finalizer string + PVCPath string + ShootNamesapace string shoot.ConverterConfig } @@ -98,7 +101,7 @@ loop: }, err } -func NewFsm(log logr.Logger, cfg RCCfg, k8s K8s) Fsm { +func NewFsm(log logr.Logger, cfg RCCfg, k8s K8s, timeoutProvision, timeoutDeprovision, timeoutUpdate time.Duration) Fsm { return &fsm{ fn: sFnTakeSnapshot, writerProvider: getWriterForFilesystem,