Skip to content

Commit ef9c4cb

Browse files
authored
Merge branch 'master' into fix-asynchronous-get-switchover-candidates-upstream
2 parents c3a9cf2 + 8231797 commit ef9c4cb

File tree

16 files changed

+177
-72
lines changed

16 files changed

+177
-72
lines changed

charts/postgres-operator/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v2
22
name: postgres-operator
3-
version: 1.13.0
3+
version: 1.14.0
44
appVersion: 1.13.0
55
home: https://github.com/zalando/postgres-operator
66
description: Postgres Operator creates and manages PostgreSQL clusters running in Kubernetes

charts/postgres-operator/crds/operatorconfigurations.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -376,28 +376,28 @@ spec:
376376
properties:
377377
default_cpu_limit:
378378
type: string
379-
pattern: '^(\d+m|\d+(\.\d{1,3})?)$'
379+
pattern: '^(\d+m|\d+(\.\d{1,3})?)$|^$'
380380
default_cpu_request:
381381
type: string
382-
pattern: '^(\d+m|\d+(\.\d{1,3})?)$'
382+
pattern: '^(\d+m|\d+(\.\d{1,3})?)$|^$'
383383
default_memory_limit:
384384
type: string
385-
pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$'
385+
pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$|^$'
386386
default_memory_request:
387387
type: string
388-
pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$'
388+
pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$|^$'
389389
max_cpu_request:
390390
type: string
391-
pattern: '^(\d+m|\d+(\.\d{1,3})?)$'
391+
pattern: '^(\d+m|\d+(\.\d{1,3})?)$|^$'
392392
max_memory_request:
393393
type: string
394-
pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$'
394+
pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$|^$'
395395
min_cpu_limit:
396396
type: string
397-
pattern: '^(\d+m|\d+(\.\d{1,3})?)$'
397+
pattern: '^(\d+m|\d+(\.\d{1,3})?)$|^$'
398398
min_memory_limit:
399399
type: string
400-
pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$'
400+
pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$|^$'
401401
timeouts:
402402
type: object
403403
properties:

charts/postgres-operator/templates/clusterrole.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ rules:
140140
- delete
141141
- get
142142
- list
143-
{{- if toString .Values.configKubernetes.storage_resize_mode | eq "pvc" }}
144143
- patch
144+
{{- if toString .Values.configKubernetes.storage_resize_mode | eq "pvc" }}
145145
- update
146146
{{- end }}
147147
# to read existing PVs. Creation should be done via dynamic provisioning

charts/postgres-operator/templates/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ spec:
5454
value: {{ template "postgres-operator.controllerID" . }}
5555
{{- end }}
5656
{{- if .Values.extraEnvs }}
57-
{{- .Values.extraEnvs | toYaml | nindent 12 }}
57+
{{- .Values.extraEnvs | toYaml | nindent 8 }}
5858
{{- end }}
5959
resources:
6060
{{ toYaml .Values.resources | indent 10 }}

docs/reference/operator_parameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ configuration they are grouped under the `kubernetes` key.
366366
manifest. To keep secrets, set this option to `false`. The default is `true`.
367367

368368
* **enable_persistent_volume_claim_deletion**
369-
By default, the operator deletes PersistentVolumeClaims when removing the
369+
By default, the operator deletes persistent volume claims when removing the
370370
Postgres cluster manifest, no matter if `persistent_volume_claim_retention_policy`
371371
on the statefulset is set to `retain`. To keep PVCs set this option to `false`.
372372
The default is `true`.

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ require (
2222
)
2323

2424
require (
25+
github.com/Masterminds/semver v1.5.0
2526
github.com/davecgh/go-spew v1.1.1 // indirect
2627
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
2728
github.com/evanphx/json-patch v4.12.0+incompatible // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
2+
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
13
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
24
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
35
github.com/aws/aws-sdk-go v1.53.8 h1:eoqGb1WOHIrCFKo1d51cMcnt1ralfLFaEqRkC5Zzv8k=

manifests/operatorconfiguration.crd.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -374,28 +374,28 @@ spec:
374374
properties:
375375
default_cpu_limit:
376376
type: string
377-
pattern: '^(\d+m|\d+(\.\d{1,3})?)$'
377+
pattern: '^(\d+m|\d+(\.\d{1,3})?)$|^$'
378378
default_cpu_request:
379379
type: string
380-
pattern: '^(\d+m|\d+(\.\d{1,3})?)$'
380+
pattern: '^(\d+m|\d+(\.\d{1,3})?)$|^$'
381381
default_memory_limit:
382382
type: string
383-
pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$'
383+
pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$|^$'
384384
default_memory_request:
385385
type: string
386-
pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$'
386+
pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$|^$'
387387
max_cpu_request:
388388
type: string
389-
pattern: '^(\d+m|\d+(\.\d{1,3})?)$'
389+
pattern: '^(\d+m|\d+(\.\d{1,3})?)$|^$'
390390
max_memory_request:
391391
type: string
392-
pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$'
392+
pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$|^$'
393393
min_cpu_limit:
394394
type: string
395-
pattern: '^(\d+m|\d+(\.\d{1,3})?)$'
395+
pattern: '^(\d+m|\d+(\.\d{1,3})?)$|^$'
396396
min_memory_limit:
397397
type: string
398-
pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$'
398+
pattern: '^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$|^$'
399399
timeouts:
400400
type: object
401401
properties:

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,35 +1573,35 @@ var OperatorConfigCRDResourceValidation = apiextv1.CustomResourceValidation{
15731573
Properties: map[string]apiextv1.JSONSchemaProps{
15741574
"default_cpu_limit": {
15751575
Type: "string",
1576-
Pattern: "^(\\d+m|\\d+(\\.\\d{1,3})?)$",
1576+
Pattern: "^(\\d+m|\\d+(\\.\\d{1,3})?)$|^$",
15771577
},
15781578
"default_cpu_request": {
15791579
Type: "string",
1580-
Pattern: "^(\\d+m|\\d+(\\.\\d{1,3})?)$",
1580+
Pattern: "^(\\d+m|\\d+(\\.\\d{1,3})?)$|^$",
15811581
},
15821582
"default_memory_limit": {
15831583
Type: "string",
1584-
Pattern: "^(\\d+(e\\d+)?|\\d+(\\.\\d+)?(e\\d+)?[EPTGMK]i?)$",
1584+
Pattern: "^(\\d+(e\\d+)?|\\d+(\\.\\d+)?(e\\d+)?[EPTGMK]i?)$|^$",
15851585
},
15861586
"default_memory_request": {
15871587
Type: "string",
1588-
Pattern: "^(\\d+(e\\d+)?|\\d+(\\.\\d+)?(e\\d+)?[EPTGMK]i?)$",
1588+
Pattern: "^(\\d+(e\\d+)?|\\d+(\\.\\d+)?(e\\d+)?[EPTGMK]i?)$|^$",
15891589
},
15901590
"max_cpu_request": {
15911591
Type: "string",
1592-
Pattern: "^(\\d+m|\\d+(\\.\\d{1,3})?)$",
1592+
Pattern: "^(\\d+m|\\d+(\\.\\d{1,3})?)$|^$",
15931593
},
15941594
"max_memory_request": {
15951595
Type: "string",
1596-
Pattern: "^(\\d+(e\\d+)?|\\d+(\\.\\d+)?(e\\d+)?[EPTGMK]i?)$",
1596+
Pattern: "^(\\d+(e\\d+)?|\\d+(\\.\\d+)?(e\\d+)?[EPTGMK]i?)$|^$",
15971597
},
15981598
"min_cpu_limit": {
15991599
Type: "string",
1600-
Pattern: "^(\\d+m|\\d+(\\.\\d{1,3})?)$",
1600+
Pattern: "^(\\d+m|\\d+(\\.\\d{1,3})?)$|^$",
16011601
},
16021602
"min_memory_limit": {
16031603
Type: "string",
1604-
Pattern: "^(\\d+(e\\d+)?|\\d+(\\.\\d+)?(e\\d+)?[EPTGMK]i?)$",
1604+
Pattern: "^(\\d+(e\\d+)?|\\d+(\\.\\d+)?(e\\d+)?[EPTGMK]i?)$|^$",
16051605
},
16061606
},
16071607
},

pkg/cluster/cluster.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ type kubeResources struct {
6565
PatroniConfigMaps map[string]*v1.ConfigMap
6666
Secrets map[types.UID]*v1.Secret
6767
Statefulset *appsv1.StatefulSet
68+
VolumeClaims map[types.UID]*v1.PersistentVolumeClaim
6869
PodDisruptionBudget *policyv1.PodDisruptionBudget
6970
LogicalBackupJob *batchv1.CronJob
7071
Streams map[string]*zalandov1.FabricEventStream
7172
//Pods are treated separately
72-
//PVCs are treated separately
7373
}
7474

7575
// Cluster describes postgresql cluster
@@ -140,6 +140,7 @@ func New(cfg Config, kubeClient k8sutil.KubernetesClient, pgSpec acidv1.Postgres
140140
Endpoints: make(map[PostgresRole]*v1.Endpoints),
141141
PatroniEndpoints: make(map[string]*v1.Endpoints),
142142
PatroniConfigMaps: make(map[string]*v1.ConfigMap),
143+
VolumeClaims: make(map[types.UID]*v1.PersistentVolumeClaim),
143144
Streams: make(map[string]*zalandov1.FabricEventStream)},
144145
userSyncStrategy: users.DefaultUserSyncStrategy{
145146
PasswordEncryption: passwordEncryption,
@@ -363,6 +364,11 @@ func (c *Cluster) Create() (err error) {
363364
c.logger.Infof("pods are ready")
364365
c.eventRecorder.Event(c.GetReference(), v1.EventTypeNormal, "StatefulSet", "Pods are ready")
365366

367+
// sync volume may already transition volumes to gp3, if iops/throughput or type is specified
368+
if err = c.syncVolumes(); err != nil {
369+
return err
370+
}
371+
366372
// sync resources created by Patroni
367373
if err = c.syncPatroniResources(); err != nil {
368374
c.logger.Warnf("Patroni resources not yet synced: %v", err)
@@ -1390,18 +1396,18 @@ func (c *Cluster) initPreparedDatabaseRoles() error {
13901396
preparedSchemas = map[string]acidv1.PreparedSchema{"data": {DefaultRoles: util.True()}}
13911397
}
13921398

1393-
var searchPath strings.Builder
1394-
searchPath.WriteString(constants.DefaultSearchPath)
1399+
searchPathArr := []string{constants.DefaultSearchPath}
13951400
for preparedSchemaName := range preparedSchemas {
1396-
searchPath.WriteString(", " + preparedSchemaName)
1401+
searchPathArr = append(searchPathArr, fmt.Sprintf("%q", preparedSchemaName))
13971402
}
1403+
searchPath := strings.Join(searchPathArr, ", ")
13981404

13991405
// default roles per database
1400-
if err := c.initDefaultRoles(defaultRoles, "admin", preparedDbName, searchPath.String(), preparedDB.SecretNamespace); err != nil {
1406+
if err := c.initDefaultRoles(defaultRoles, "admin", preparedDbName, searchPath, preparedDB.SecretNamespace); err != nil {
14011407
return fmt.Errorf("could not initialize default roles for database %s: %v", preparedDbName, err)
14021408
}
14031409
if preparedDB.DefaultUsers {
1404-
if err := c.initDefaultRoles(defaultUsers, "admin", preparedDbName, searchPath.String(), preparedDB.SecretNamespace); err != nil {
1410+
if err := c.initDefaultRoles(defaultUsers, "admin", preparedDbName, searchPath, preparedDB.SecretNamespace); err != nil {
14051411
return fmt.Errorf("could not initialize default roles for database %s: %v", preparedDbName, err)
14061412
}
14071413
}
@@ -1412,14 +1418,16 @@ func (c *Cluster) initPreparedDatabaseRoles() error {
14121418
if err := c.initDefaultRoles(defaultRoles,
14131419
preparedDbName+constants.OwnerRoleNameSuffix,
14141420
preparedDbName+"_"+preparedSchemaName,
1415-
constants.DefaultSearchPath+", "+preparedSchemaName, preparedDB.SecretNamespace); err != nil {
1421+
fmt.Sprintf("%s, %q", constants.DefaultSearchPath, preparedSchemaName),
1422+
preparedDB.SecretNamespace); err != nil {
14161423
return fmt.Errorf("could not initialize default roles for database schema %s: %v", preparedSchemaName, err)
14171424
}
14181425
if preparedSchema.DefaultUsers {
14191426
if err := c.initDefaultRoles(defaultUsers,
14201427
preparedDbName+constants.OwnerRoleNameSuffix,
14211428
preparedDbName+"_"+preparedSchemaName,
1422-
constants.DefaultSearchPath+", "+preparedSchemaName, preparedDB.SecretNamespace); err != nil {
1429+
fmt.Sprintf("%s, %q", constants.DefaultSearchPath, preparedSchemaName),
1430+
preparedDB.SecretNamespace); err != nil {
14231431
return fmt.Errorf("could not initialize default users for database schema %s: %v", preparedSchemaName, err)
14241432
}
14251433
}

0 commit comments

Comments
 (0)