Skip to content

Commit

Permalink
db upgrage: upgrade postgres 15 to postgres 16
Browse files Browse the repository at this point in the history
The Postgres upgrade from 15 to 16 or any later versions can be done by adding the env variable named POSTGRES_UPGRADE = copy in the pg db pod.

More about upgrade process is here: https://www.postgresql.org/docs/current/pgupgrade.html

In our case, we achieve the upgrade by setting this env var in noobaa-db-pg STS.

Once after upgrade is done, we have to remove the POSTGRES_UPGRADE env from the STS. Otherwise pg db pod fails to come up because the db pod check PG directory version against upgrade image version and exits if there is no upgrade required and POSTGRES_UPGRADE is still provided.

To remove this env, we store the upgrade status in noobaa-core CR after the PG upgrade and refer the same status during db reconcile. If the upgrade is already done, we remove this env from desired sts status.

This will help to upgrade the db smoothly.

Signed-off-by: Vinayak Hariharmath <vharihar@redhat.com>
  • Loading branch information
vec-tr committed Dec 16, 2024
1 parent 1fd00fb commit a407bc0
Show file tree
Hide file tree
Showing 5 changed files with 302 additions and 21 deletions.
4 changes: 4 additions & 0 deletions deploy/crds/noobaa.io_noobaas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1911,6 +1911,10 @@ spec:
description: Phase is a simple, high-level summary of where the System
is in its lifecycle
type: string
postgresMajorVersion:
description: PostgresMajorVersion is the major version of postgress
db image
type: string
postgresUpdatePhase:
description: Upgrade reports the status of the ongoing postgres upgrade
process
Expand Down
12 changes: 11 additions & 1 deletion pkg/apis/noobaa/v1alpha1/noobaa_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,10 @@ type NooBaaStatus struct {
// BeforeUpgradeDbImage is the db image used before last db upgrade
// +optional
BeforeUpgradeDbImage *string `json:"beforeUpgradeDbImage,omitempty"`

// PostgresMajorVersion is the major version of postgress db image
// +optional
PostgresMajorVersion PostgresMajorVersion `json:"postgresMajorVersion,omitempty"`
}

// SystemPhase is a string enum type for system phases
Expand Down Expand Up @@ -514,6 +518,12 @@ type EndpointsStatus struct {
VirtualHosts []string `json:"virtualHosts"`
}

type PostgresMajorVersion string

const (
PostgresMajorVersionV16 PostgresMajorVersion = "16"
)

// UpgradePhase is a string enum type for upgrade phases
type UpgradePhase string

Expand All @@ -525,7 +535,7 @@ const (

UpgradePhaseMigrate UpgradePhase = "Migrating"

UpgradePhaseClean UpgradePhase = "Cleanning"
UpgradePhaseClean UpgradePhase = "Cleaning"

UpgradePhaseFinished UpgradePhase = "DoneUpgrade"

Expand Down
6 changes: 5 additions & 1 deletion pkg/bundle/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@ spec:
status: {}
`

const Sha256_deploy_crds_noobaa_io_noobaas_yaml = "e862d263d097ed43f774784eaaf9a616967746b67608fadbe4ca71d93b220ab6"
const Sha256_deploy_crds_noobaa_io_noobaas_yaml = "5bfeed22b7201dfc6d56cda47e573dc0f5cac7350806b142c76509ad73b070b0"

const File_deploy_crds_noobaa_io_noobaas_yaml = `---
apiVersion: apiextensions.k8s.io/v1
Expand Down Expand Up @@ -3338,6 +3338,10 @@ spec:
description: Phase is a simple, high-level summary of where the System
is in its lifecycle
type: string
postgresMajorVersion:
description: PostgresMajorVersion is the major version of postgress
db image
type: string
postgresUpdatePhase:
description: Upgrade reports the status of the ongoing postgres upgrade
process
Expand Down
7 changes: 6 additions & 1 deletion pkg/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/noobaa/noobaa-operator/v5/pkg/util"
"github.com/noobaa/noobaa-operator/v5/version"

nbv1 "github.com/noobaa/noobaa-operator/v5/pkg/apis/noobaa/v1alpha1"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
Expand Down Expand Up @@ -72,7 +73,11 @@ var NooBaaImage = ContainerImage

// DBImage is the default db image url
// it can be overridden for testing or different registry locations.
var DBImage = "quay.io/sclorg/postgresql-15-c9s"
var DBImage = "quay.io/sclorg/postgresql-16-c9s"

// Postgress Major version is the major version of Postgress image
// This is referred for postgres upgrade.
var PostgresMajorVersion = nbv1.PostgresMajorVersionV16

// Psql12Image is the default postgres12 db image url
// currently it can not be overridden.
Expand Down
Loading

0 comments on commit a407bc0

Please sign in to comment.