Skip to content

Commit e947889

Browse files
authored
Avoid rotating pods for PGVERSION change outside of maintenance window (#3065)
* Avoid rotating pods for PGVERSION change outside of maintenance window * Update docs
1 parent 421bd6d commit e947889

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

docs/administrator.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ the `PGVERSION` environment variable is set for the database pods. Since
6565
In-place major version upgrades can be configured to be executed by the
6666
operator with the `major_version_upgrade_mode` option. By default, it is
6767
enabled (mode: `manual`). In any case, altering the version in the manifest
68-
will trigger a rolling update of pods to update the `PGVERSION` env variable.
68+
will update the desired `PGVERSION`. If `maintenanceWindows` are configured,
69+
major-version-related pod rotation is deferred until the next maintenance
70+
window. Without maintenance windows, the operator will trigger a rolling
71+
update of pods to apply the new `PGVERSION`.
6972
Spilo's [`configure_spilo`](https://github.com/zalando/spilo/blob/master/postgres-appliance/scripts/configure_spilo.py)
7073
script will notice the version mismatch but start the current version again.
7174

@@ -93,8 +96,9 @@ Thus, the `full` mode can create drift between desired and actual state.
9396
### Upgrade during maintenance windows
9497

9598
When `maintenanceWindows` are defined in the Postgres manifest the operator
96-
will trigger a major version upgrade only during these periods. Make sure they
97-
are at least twice as long as your configured `resync_period` to guarantee
99+
will trigger major-version-related pod rotation and the major version upgrade
100+
only during these periods. Make sure they are at least twice as long as your
101+
configured `resync_period` to guarantee
98102
that operator actions can be triggered.
99103

100104
### Upgrade annotations

pkg/cluster/sync.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ func (c *Cluster) Sync(newSpec *acidv1.Postgresql) error {
4141
defer c.mu.Unlock()
4242

4343
oldSpec := c.Postgresql
44+
45+
if !c.isInMaintenanceWindow(newSpec.Spec.MaintenanceWindows) {
46+
// do not apply any major version related changes yet
47+
newSpec.Spec.PostgresqlParam.PgVersion = oldSpec.Spec.PostgresqlParam.PgVersion
48+
}
49+
4450
c.setSpec(newSpec)
4551

4652
defer func() {
@@ -97,11 +103,6 @@ func (c *Cluster) Sync(newSpec *acidv1.Postgresql) error {
97103
}
98104
}
99105

100-
if !c.isInMaintenanceWindow(newSpec.Spec.MaintenanceWindows) {
101-
// do not apply any major version related changes yet
102-
newSpec.Spec.PostgresqlParam.PgVersion = oldSpec.Spec.PostgresqlParam.PgVersion
103-
}
104-
105106
if err = c.syncStatefulSet(); err != nil {
106107
if !k8sutil.ResourceAlreadyExists(err) {
107108
err = fmt.Errorf("could not sync statefulsets: %v", err)

0 commit comments

Comments
 (0)