From f782181fd4ae73c8d3a5c2cf7892f6b97d713662 Mon Sep 17 00:00:00 2001 From: Sergey Dudoladov Date: Tue, 10 Mar 2020 13:29:31 +0100 Subject: [PATCH] make parameter name more descriptive --- .../crds/operatorconfigurations.yaml | 2 +- docs/administrator.md | 2 +- docs/reference/operator_parameters.md | 2 +- e2e/tests/test_e2e.py | 14 +++++++------- manifests/configmap.yaml | 2 +- manifests/operatorconfiguration.crd.yaml | 2 +- .../postgresql-operator-default-configuration.yaml | 2 +- pkg/cluster/cluster.go | 4 ++-- pkg/cluster/sync.go | 2 +- pkg/util/config/config.go | 2 +- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/charts/postgres-operator/crds/operatorconfigurations.yaml b/charts/postgres-operator/crds/operatorconfigurations.yaml index 03ec43f80..51c8012de 100644 --- a/charts/postgres-operator/crds/operatorconfigurations.yaml +++ b/charts/postgres-operator/crds/operatorconfigurations.yaml @@ -62,7 +62,7 @@ spec: type: string enable_crd_validation: type: boolean - enable_lazy_image_upgrade: + enable_lazy_spilo_upgrade: type: boolean enable_shm_volume: type: boolean diff --git a/docs/administrator.md b/docs/administrator.md index ff91daa1f..b74c74537 100644 --- a/docs/administrator.md +++ b/docs/administrator.md @@ -431,7 +431,7 @@ used internally in K8s. The operator also support lazy updates of the Spilo image. That means the pod template of a PG cluster's stateful set is updated immediately with the new image, but no rolling update follows. This feature saves you -a switchover - and hence downtime - when you know pods are re-started later anyway, for instance due to the node rotation. To force a rolling update, disable this mode by setting the `enable_lazy_image_upgrade` to `false` in the operator configuration and restart the operator pod. With the standard eager rolling updates the operator checks during Sync all pods run images specified in their respective statefulsets. The operator triggers a rolling upgrade fo PG clusters that violate this condition. +a switchover - and hence downtime - when you know pods are re-started later anyway, for instance due to the node rotation. To force a rolling update, disable this mode by setting the `enable_lazy_spilo_upgrade` to `false` in the operator configuration and restart the operator pod. With the standard eager rolling updates the operator checks during Sync all pods run images specified in their respective statefulsets. The operator triggers a rolling upgrade fo PG clusters that violate this condition. ## Logical backups diff --git a/docs/reference/operator_parameters.md b/docs/reference/operator_parameters.md index 3f51e30fb..7bb4fd29f 100644 --- a/docs/reference/operator_parameters.md +++ b/docs/reference/operator_parameters.md @@ -75,7 +75,7 @@ Those are top-level keys, containing both leaf keys and groups. [OpenAPI v3 schema validation](https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#validation) The default is `true`. -* **enable_lazy_image_upgrade** +* **enable_lazy_spilo_upgrade** Instruct operator to update only the statefulsets with the new image without immediately doing the rolling update. The assumption is pods will be re-started later with the new image, for example due to the node rotation. The default is `false`. diff --git a/e2e/tests/test_e2e.py b/e2e/tests/test_e2e.py index f21106ff1..79308e7d7 100644 --- a/e2e/tests/test_e2e.py +++ b/e2e/tests/test_e2e.py @@ -109,7 +109,7 @@ class EndToEndTestCase(unittest.TestCase): "Expected ClusterIP service type for replica, found {}".format(repl_svc_type)) @timeout_decorator.timeout(TEST_TIMEOUT_SEC) - def test_lazy_image_update(self): + def test_lazy_spilo_update(self): ''' Test lazy update for the Spilo image: operator changes a stateful set but lets pods run with the old image until they are recreated for reasons other than operator's activity. That works because the operator uses @@ -125,13 +125,13 @@ class EndToEndTestCase(unittest.TestCase): pod1 = "acid-minimal-cluster-1" # enable lazy update - patch_lazy_image_upgrade = { + patch_lazy_spilo_upgrade = { "data": { - "enable_lazy_image_upgrade": "true", + "enable_lazy_spilo_upgrade": "true", "docker_image": "registry.opensource.zalan.do/acid/spilo-cdp-12:1.6-p16" } } - k8s.update_config(patch_lazy_image_upgrade) + k8s.update_config(patch_lazy_spilo_upgrade) # wait for sts update time.sleep(60) @@ -147,12 +147,12 @@ class EndToEndTestCase(unittest.TestCase): self.assertNotEqual(old_image, new_image, "Lazy updated failed: pods have the same image {}".format(new_image)) # clean up - unpatch_lazy_image_upgrade = { + unpatch_lazy_spilo_upgrade = { "data": { - "enable_lazy_image_upgrade": "false", + "enable_lazy_spilo_upgrade": "false", } } - k8s.update_config(unpatch_lazy_image_upgrade) + k8s.update_config(unpatch_lazy_spilo_upgrade) # at this point operator will complete the normal rolling update # so we additonally test if disabling the lazy update (forcing the normal rolling update) works diff --git a/manifests/configmap.yaml b/manifests/configmap.yaml index 043780668..80c9a661f 100644 --- a/manifests/configmap.yaml +++ b/manifests/configmap.yaml @@ -24,7 +24,7 @@ data: # enable_crd_validation: "true" # enable_database_access: "true" # enable_init_containers: "true" - # enable_lazy_image_upgrade: "true" + # enable_lazy_spilo_upgrade: "true" enable_master_load_balancer: "false" # enable_pod_antiaffinity: "false" # enable_pod_disruption_budget: "true" diff --git a/manifests/operatorconfiguration.crd.yaml b/manifests/operatorconfiguration.crd.yaml index bfcac813d..957a7b198 100644 --- a/manifests/operatorconfiguration.crd.yaml +++ b/manifests/operatorconfiguration.crd.yaml @@ -38,7 +38,7 @@ spec: type: string enable_crd_validation: type: boolean - enable_lazy_image_upgrade: + enable_lazy_spilo_upgrade: type: boolean enable_shm_volume: type: boolean diff --git a/manifests/postgresql-operator-default-configuration.yaml b/manifests/postgresql-operator-default-configuration.yaml index f605ccdee..712908019 100644 --- a/manifests/postgresql-operator-default-configuration.yaml +++ b/manifests/postgresql-operator-default-configuration.yaml @@ -4,7 +4,7 @@ metadata: name: postgresql-operator-default-configuration configuration: # enable_crd_validation: true - # enable_lazy_image_upgrade: true + # enable_lazy_spilo_upgrade: true etcd_host: "" docker_image: registry.opensource.zalan.do/acid/spilo-12:1.6-p2 # enable_shm_volume: true diff --git a/pkg/cluster/cluster.go b/pkg/cluster/cluster.go index f90557611..71ebd13fc 100644 --- a/pkg/cluster/cluster.go +++ b/pkg/cluster/cluster.go @@ -411,7 +411,7 @@ func (c *Cluster) compareStatefulSetWith(statefulSet *appsv1.StatefulSet) *compa // lazy Spilo update: modify the image in the statefulset itself but let its pods run with the old image // until they are re-created for other reasons, for example node rotation - if c.OpConfig.EnableLazyImageUpgrade && !reflect.DeepEqual(c.Statefulset.Spec.Template.Spec.Containers[0].Image, statefulSet.Spec.Template.Spec.Containers[0].Image) { + if c.OpConfig.EnableLazySpiloUpgrade && !reflect.DeepEqual(c.Statefulset.Spec.Template.Spec.Containers[0].Image, statefulSet.Spec.Template.Spec.Containers[0].Image) { needsReplace = true needsRollUpdate = false reasons = append(reasons, "lazy Spilo update: new statefulset's pod image doesn't match the current one") @@ -458,7 +458,7 @@ func (c *Cluster) compareContainers(description string, setA, setB []v1.Containe func(a, b v1.Container) bool { return !reflect.DeepEqual(a.EnvFrom, b.EnvFrom) }), } - if !c.OpConfig.EnableLazyImageUpgrade { + if !c.OpConfig.EnableLazySpiloUpgrade { checks = append(checks, newCheck("new statefulset %s's %s (index %d) image doesn't match the current one", func(a, b v1.Container) bool { return a.Image != b.Image })) } diff --git a/pkg/cluster/sync.go b/pkg/cluster/sync.go index 472b2acc1..342f93c45 100644 --- a/pkg/cluster/sync.go +++ b/pkg/cluster/sync.go @@ -246,7 +246,7 @@ func (c *Cluster) syncPodDisruptionBudget(isUpdate bool) error { func (c *Cluster) mustUpdatePodsAfterLazyUpdate(desiredSset *appsv1.StatefulSet) (bool, error) { - if c.OpConfig.EnableLazyImageUpgrade { + if c.OpConfig.EnableLazySpiloUpgrade { return false, nil } diff --git a/pkg/util/config/config.go b/pkg/util/config/config.go index 4e65814b1..c5b9455fc 100644 --- a/pkg/util/config/config.go +++ b/pkg/util/config/config.go @@ -137,7 +137,7 @@ type Config struct { ProtectedRoles []string `name:"protected_role_names" default:"admin"` PostgresSuperuserTeams []string `name:"postgres_superuser_teams" default:""` SetMemoryRequestToLimit bool `name:"set_memory_request_to_limit" default:"false"` - EnableLazyImageUpgrade bool `name:"enable_lazy_image_upgrade" default:"false"` + EnableLazySpiloUpgrade bool `name:"enable_lazy_spilo_upgrade" default:"false"` } // MustMarshal marshals the config or panics