Skip to content

Commit 83fbcca

Browse files
authored
new env var for backwards compatability between spilo 12 and 13 (#1254)
1 parent 028f23e commit 83fbcca

File tree

12 files changed

+35
-5
lines changed

12 files changed

+35
-5
lines changed

charts/postgres-operator/crds/operatorconfigurations.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ spec:
7373
type: boolean
7474
enable_shm_volume:
7575
type: boolean
76+
enable_spilo_wal_path_compat:
77+
type: boolean
7678
etcd_host:
7779
type: string
7880
kubernetes_use_configmaps:

charts/postgres-operator/values-crd.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ configGeneral:
2525
enable_pgversion_env_var: false
2626
# start any new database pod without limitations on shm memory
2727
enable_shm_volume: true
28+
# enables backwards compatible path between Spilo 12 and Spilo 13 images
29+
enable_spilo_wal_path_compat: false
2830
# etcd connection string for Patroni. Empty uses K8s-native DCS.
2931
etcd_host: ""
3032
# Select if setup uses endpoints (default), or configmaps to manage leader (DCS=k8s)

charts/postgres-operator/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ configGeneral:
2828
enable_pgversion_env_var: "false"
2929
# start any new database pod without limitations on shm memory
3030
enable_shm_volume: "true"
31+
# enables backwards compatible path between Spilo 12 and Spilo 13 images
32+
enable_spilo_wal_path_compat: "false"
3133
# etcd connection string for Patroni. Empty uses K8s-native DCS.
3234
etcd_host: ""
3335
# Select if setup uses endpoints (default), or configmaps to manage leader (DCS=k8s)

docs/reference/operator_parameters.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ Those are top-level keys, containing both leaf keys and groups.
7979
Instruct operator to update only the statefulsets with new images (Spilo and InitContainers) without immediately doing the rolling update. The assumption is pods will be re-started later with new images, for example due to the node rotation.
8080
The default is `false`.
8181

82+
* **enable_pgversion_env_var**
83+
With newer versions of Spilo, it is preferable to use `PGVERSION` pod environment variable instead of the setting `postgresql.bin_dir` in the `SPILO_CONFIGURATION` env variable. When this option is true, the operator sets `PGVERSION` and omits `postgresql.bin_dir` from `SPILO_CONFIGURATION`. When false, the `postgresql.bin_dir` is set. This setting takes precedence over `PGVERSION`; see PR 222 in Spilo. The default is `false`.
84+
85+
* **enable_spilo_wal_path_compat**
86+
enables backwards compatible path between Spilo 12 and Spilo 13 images. The default is `false`.
87+
8288
* **etcd_host**
8389
Etcd connection string for Patroni defined as `host:port`. Not required when
8490
Patroni native Kubernetes support is used. The default is empty (use
@@ -118,9 +124,6 @@ Those are top-level keys, containing both leaf keys and groups.
118124
This option is global for an operator object, and can be overwritten by
119125
`enableShmVolume` parameter from Postgres manifest. The default is `true`.
120126

121-
* **enable_pgversion_env_var**
122-
With newer versions of Spilo, it is preferable to use `PGVERSION` pod environment variable instead of the setting `postgresql.bin_dir` in the `SPILO_CONFIGURATION` env variable. When this option is true, the operator sets `PGVERSION` and omits `postgresql.bin_dir` from `SPILO_CONFIGURATION`. When false, the `postgresql.bin_dir` is set. This setting takes precedence over `PGVERSION`; see PR 222 in Spilo. The default is `false`.
123-
124127
* **workers**
125128
number of working routines the operator spawns to process requests to
126129
create/update/delete/sync clusters concurrently. The default is `4`.

manifests/configmap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ data:
5050
# enable_shm_volume: "true"
5151
# enable_pgversion_env_var: "false"
5252
# enable_sidecars: "true"
53+
enable_spilo_wal_path_compat: "false"
5354
# enable_team_superuser: "false"
5455
enable_teams_api: "false"
5556
# etcd_host: ""

manifests/operatorconfiguration.crd.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ spec:
6969
type: boolean
7070
enable_shm_volume:
7171
type: boolean
72+
enable_spilo_wal_path_compat:
73+
type: boolean
7274
etcd_host:
7375
type: string
7476
kubernetes_use_configmaps:

manifests/postgresql-operator-default-configuration.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ configuration:
88
# enable_lazy_spilo_upgrade: false
99
# enable_pgversion_env_var: false
1010
# enable_shm_volume: true
11+
enable_spilo_wal_path_compat: false
1112
etcd_host: ""
1213
# kubernetes_use_configmaps: false
1314
max_instances: -1

pkg/apis/acid.zalan.do/v1/crds.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,9 @@ var OperatorConfigCRDResourceValidation = apiextv1.CustomResourceValidation{
815815
"enable_shm_volume": {
816816
Type: "boolean",
817817
},
818+
"enable_spilo_wal_path_compat": {
819+
Type: "boolean",
820+
},
818821
"etcd_host": {
819822
Type: "string",
820823
},

pkg/apis/acid.zalan.do/v1/operator_configuration_type.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ type OperatorConfigurationData struct {
201201
EnableCRDValidation *bool `json:"enable_crd_validation,omitempty"`
202202
EnableLazySpiloUpgrade bool `json:"enable_lazy_spilo_upgrade,omitempty"`
203203
EnablePgVersionEnvVar bool `json:"enable_pgversion_env_var,omitempty"`
204+
EnableSpiloWalPathCompat bool `json:"enable_spilo_wal_path_compat,omitempty"`
204205
EtcdHost string `json:"etcd_host,omitempty"`
205206
KubernetesUseConfigMaps bool `json:"kubernetes_use_configmaps,omitempty"`
206207
DockerImage string `json:"docker_image,omitempty"`

pkg/cluster/k8sres.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ func (c *Cluster) getPodEnvironmentConfigMapVariables() ([]v1.EnvVar, error) {
824824
return configMapPodEnvVarsList, nil
825825
}
826826

827-
// Return list of variables the pod recieved from the configured Secret
827+
// Return list of variables the pod received from the configured Secret
828828
func (c *Cluster) getPodEnvironmentSecretVariables() ([]v1.EnvVar, error) {
829829
secretPodEnvVarsList := make([]v1.EnvVar, 0)
830830

@@ -979,6 +979,16 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
979979
initContainers = spec.InitContainers
980980
}
981981

982+
spiloCompathWalPathList := make([]v1.EnvVar, 0)
983+
if c.OpConfig.EnableSpiloWalPathCompat {
984+
spiloCompathWalPathList = append(spiloCompathWalPathList,
985+
v1.EnvVar{
986+
Name: "ENABLE_WAL_PATH_COMPAT",
987+
Value: "true",
988+
},
989+
)
990+
}
991+
982992
// fetch env vars from custom ConfigMap
983993
configMapEnvVarsList, err := c.getPodEnvironmentConfigMapVariables()
984994
if err != nil {
@@ -992,7 +1002,8 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
9921002
}
9931003

9941004
// concat all custom pod env vars and sort them
995-
customPodEnvVarsList := append(configMapEnvVarsList, secretEnvVarsList...)
1005+
customPodEnvVarsList := append(spiloCompathWalPathList, configMapEnvVarsList...)
1006+
customPodEnvVarsList = append(customPodEnvVarsList, secretEnvVarsList...)
9961007
sort.Slice(customPodEnvVarsList,
9971008
func(i, j int) bool { return customPodEnvVarsList[i].Name < customPodEnvVarsList[j].Name })
9981009

0 commit comments

Comments
 (0)