From 2b6a1b0932d045b6eb8e822cb26e43aac1094328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Drzewiecki?= Date: Tue, 23 Jul 2024 12:41:09 +0200 Subject: [PATCH] renames persist-shoot to dump-shoot-spec --- cmd/main.go | 7 +++---- docs/README.md | 1 + .../controller/runtime/fsm/runtime_fsm_create_shoot.go | 6 +++--- internal/controller/runtime/fsm/runtime_fsm_patch_shoot.go | 6 +++--- .../controller/runtime/fsm/runtime_fsm_persist_shoot.go | 2 +- .../runtime/fsm/runtime_fsm_persist_shoot_test.go | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 37390e74..5c400e73 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -72,8 +72,8 @@ func main() { var expirationTime time.Duration var gardenerRequestTimeout time.Duration var enableRuntimeReconciler bool - var persistShoot bool var converterConfigFilepath string + var shootSpecDumpEnabled bool 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.") @@ -86,8 +86,8 @@ func main() { flag.DurationVar(&expirationTime, "kubeconfig-expiration-time", defaultExpirationTime, "Dynamic kubeconfig expiration time") flag.DurationVar(&gardenerRequestTimeout, "gardener-request-timeout", defaultGardenerRequestTimeout, "Timeout duration for requests to Gardener") flag.BoolVar(&enableRuntimeReconciler, "runtime-reconciler-enabled", defaultRuntimeReconcilerEnabled, "Feature flag for all runtime reconciler functionalities") - flag.BoolVar(&persistShoot, "persist-shoot", false, "Feature flag to allow persisting created shoots") 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") opts := zap.Options{ Development: true, @@ -174,8 +174,7 @@ func main() { ShootNamesapace: gardenerNamespace, ConverterConfig: converterConfig, } - - if persistShoot { + if shootSpecDumpEnabled { cfg.PVCPath = "/testdata/kim" } diff --git a/docs/README.md b/docs/README.md index f2a23fae..2d557b18 100644 --- a/docs/README.md +++ b/docs/README.md @@ -17,6 +17,7 @@ You can configure the Infrastructure Manager deployment with the following argum 4. `kubeconfig-expiration-time` - maximum time after which kubeconfig is rotated. The rotation happens between (`minimal-rotation-time` * `kubeconfig-expiration-time`) and `kubeconfig-expiration-time`. 4. `gardener-request-timeout` - specifies the timeout for requests to Gardener. Default value is `60s`. 5. `runtime-reconciler-enabled` - feature flag responsible for enabling the runtime reconciler. Default value is `false`. +6. `shoot-spec-dump-enabled` - feature flag responsible for enabling the shoot spec dump. Default value is `false`. See [manager_gardener_secret_patch.yaml](../config/default/manager_gardener_secret_patch.yaml) for default values. diff --git a/internal/controller/runtime/fsm/runtime_fsm_create_shoot.go b/internal/controller/runtime/fsm/runtime_fsm_create_shoot.go index 186d84c0..1f53f5e0 100644 --- a/internal/controller/runtime/fsm/runtime_fsm_create_shoot.go +++ b/internal/controller/runtime/fsm/runtime_fsm_create_shoot.go @@ -38,10 +38,10 @@ func sFnCreateShoot(ctx context.Context, m *fsm, s *systemState) (stateFn, *ctrl ) // it will be executed only once because created shoot is executed only once - shouldPersistShoot := m.PVCPath != "" - if shouldPersistShoot { + shouldDumpShootSpec := m.PVCPath != "" + if shouldDumpShootSpec { s.shoot = newShoot.DeepCopy() - return switchState(sFnPersistShoot) + return switchState(sFnDumpShootSpec) } return updateStatusAndRequeueAfter(gardenerRequeueDuration) diff --git a/internal/controller/runtime/fsm/runtime_fsm_patch_shoot.go b/internal/controller/runtime/fsm/runtime_fsm_patch_shoot.go index e5d475dc..45251fd4 100644 --- a/internal/controller/runtime/fsm/runtime_fsm_patch_shoot.go +++ b/internal/controller/runtime/fsm/runtime_fsm_patch_shoot.go @@ -48,9 +48,9 @@ func sFnPatchExistingShoot(ctx context.Context, m *fsm, s *systemState) (stateFn "Shoot is pending", ) - shouldPersistShoot := m.PVCPath != "" - if shouldPersistShoot { - return switchState(sFnPersistShoot) + shouldDumpShootSpec := m.PVCPath != "" + if shouldDumpShootSpec { + return switchState(sFnDumpShootSpec) } return updateStatusAndRequeueAfter(gardenerRequeueDuration) diff --git a/internal/controller/runtime/fsm/runtime_fsm_persist_shoot.go b/internal/controller/runtime/fsm/runtime_fsm_persist_shoot.go index 043fe874..49161f33 100644 --- a/internal/controller/runtime/fsm/runtime_fsm_persist_shoot.go +++ b/internal/controller/runtime/fsm/runtime_fsm_persist_shoot.go @@ -36,7 +36,7 @@ func persist(path string, s *gardener.Shoot, saveFunc writerGetter) error { return nil } -func sFnPersistShoot(_ context.Context, m *fsm, s *systemState) (stateFn, *ctrl.Result, error) { +func sFnDumpShootSpec(_ context.Context, m *fsm, s *systemState) (stateFn, *ctrl.Result, error) { path := fmt.Sprintf("%s/%s-%s.yaml", m.PVCPath, s.shoot.Namespace, s.shoot.Name) if err := persist(path, s.shoot, m.writerProvider); err != nil { return updateStatusAndStopWithError(err) diff --git a/internal/controller/runtime/fsm/runtime_fsm_persist_shoot_test.go b/internal/controller/runtime/fsm/runtime_fsm_persist_shoot_test.go index 4bf6d56c..b35f6017 100644 --- a/internal/controller/runtime/fsm/runtime_fsm_persist_shoot_test.go +++ b/internal/controller/runtime/fsm/runtime_fsm_persist_shoot_test.go @@ -27,8 +27,8 @@ var _ = Describe("KIM sFnPersist", func() { expectedData, err := yaml.Marshal(&testing.ShootNoDNS) Expect(err).ShouldNot(HaveOccurred()) - It("shoutld persist shoot data", func() { - next, _, err := sFnPersistShoot(testCtx, must(newFakeFSM, withStorageWriter(testWriterGetter)), &systemState{shoot: &testing.ShootNoDNS}) + It("should persist shoot data", func() { + next, _, err := sFnDumpShootSpec(testCtx, must(newFakeFSM, withStorageWriter(testWriterGetter)), &systemState{shoot: &testing.ShootNoDNS}) Expect(err).To(BeNil()) Expect(next).To(haveName("sFnUpdateStatus")) Expect(expectedData).To(Equal(b.Bytes()))