Skip to content

Commit

Permalink
add upgrade process for postgres DB version 15
Browse files Browse the repository at this point in the history
Signed-off-by: nadav mizrahi <[email protected]>
  • Loading branch information
nadavMiz committed Sep 21, 2023
1 parent 7aa4663 commit 54cac98
Show file tree
Hide file tree
Showing 6 changed files with 285 additions and 7 deletions.
8 changes: 8 additions & 0 deletions deploy/crds/noobaa.io_noobaas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,10 @@ spec:
description: ActualImage is set to report which image the operator
is using
type: string
beforeUpgradeDbImage:
description: LastKeyRotateTime is the time system ran an encryption
key rotate
type: string
conditions:
description: Conditions is a list of conditions related to operator
reconciliation
Expand Down Expand Up @@ -1665,6 +1669,10 @@ spec:
description: Phase is a simple, high-level summary of where the System
is in its lifecycle
type: string
postgresUpdatePhase:
description: Upgrade reports the status of the ongoing postgres upgrade
process
type: string
readme:
description: Readme is a user readable string with explanations on
the system
Expand Down
31 changes: 31 additions & 0 deletions deploy/internal/configmap-postgres-initdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,34 @@ data:
-e 's/^pg_ctl\sstart.*/pg_ctl start || true/' \
/usr/bin/run-postgresql
su postgres -c "bash -x /usr/bin/run-postgresql"
dumpdb.sh: |
set -e
sed -i -e 's/^\(postgres:[^:]\):[0-9]*:[0-9]*:/\1:10001:0:/' /etc/passwd
su postgres -c "bash -x /usr/bin/run-postgresql" &
until pg_isready; do sleep 1; done;
pg_dumpall -U postgres > /$HOME/data/dump.sql
exit 0
upgradedb.sh: |
set -e
PGDATA=$HOME/data/userdata
PGDATA_new=$HOME/data/userdata-new
mv $PGDATA $PGDATA_new
sed -i -e 's/^\(postgres:[^:]\):[0-9]*:[0-9]*:/\1:10001:0:/' /etc/passwd
su postgres -c "bash -x /usr/bin/run-postgresql" &
until pg_isready; do sleep 1; done;
psql -U postgres < /$HOME/data/dump.sql
rm /$HOME/data/dump.sql
rm -rf $PGDATA_new
exit 0
revertdb.sh: |
PGDATA=$HOME/data/userdata
PGDATA_new=$HOME/data/userdata-new
if [ -d $PGDATA_new ]; then
rm -rf $PGDATA
mv $PGDATA_new $PGDATA
fi
exit 0
12 changes: 12 additions & 0 deletions pkg/apis/noobaa/v1alpha1/noobaa_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,21 @@ type NooBaaStatus struct {
// +optional
UpgradePhase UpgradePhase `json:"upgradePhase,omitempty"`

// Upgrade reports the status of the ongoing postgres upgrade process
// +optional
PostgresUpdatePhase UpgradePhase `json:"postgresUpdatePhase,omitempty"`

// Readme is a user readable string with explanations on the system
// +optional
Readme string `json:"readme,omitempty"`

// LastKeyRotateTime is the time system ran an encryption key rotate
// +optional
LastKeyRotateTime metav1.Time `json:"lastKeyRotateTime,omitempty"`

// LastKeyRotateTime is the time system ran an encryption key rotate
// +optional
BeforeUpgradeDbImage *string `json:"beforeUpgradeDbImage,omitempty"`
}

// SystemPhase is a string enum type for system phases
Expand Down Expand Up @@ -460,6 +468,10 @@ const (
UpgradePhaseClean UpgradePhase = "Cleanning"

UpgradePhaseFinished UpgradePhase = "DoneUpgrade"

UpgradePhaseFailed UpgradePhase = "Reverting"

UpgradePhaseUpgrade UpgradePhase = "Upgrading"
)

// CleanupPolicySpec specifies the cleanup policy
Expand Down
43 changes: 41 additions & 2 deletions pkg/bundle/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,7 @@ spec:
status: {}
`

const Sha256_deploy_crds_noobaa_io_noobaas_yaml = "a4f5cbe942a050321ada72a0c77e61898d65000b6074e72d784cf1c0ef1816a3"
const Sha256_deploy_crds_noobaa_io_noobaas_yaml = "4307c8a8772415a870e06fea98d68e82b7a6e2c22567e31016c6aba8a3fbf57e"

const File_deploy_crds_noobaa_io_noobaas_yaml = `---
apiVersion: apiextensions.k8s.io/v1
Expand Down Expand Up @@ -3075,6 +3075,10 @@ spec:
description: ActualImage is set to report which image the operator
is using
type: string
beforeUpgradeDbImage:
description: LastKeyRotateTime is the time system ran an encryption
key rotate
type: string
conditions:
description: Conditions is a list of conditions related to operator
reconciliation
Expand Down Expand Up @@ -3134,6 +3138,10 @@ spec:
description: Phase is a simple, high-level summary of where the System
is in its lifecycle
type: string
postgresUpdatePhase:
description: Upgrade reports the status of the ongoing postgres upgrade
process
type: string
readme:
description: Readme is a user readable string with explanations on
the system
Expand Down Expand Up @@ -3612,7 +3620,7 @@ data:
shared_preload_libraries = 'pg_stat_statements'
`

const Sha256_deploy_internal_configmap_postgres_initdb_yaml = "016881f9a5e0561dbf10e7034dead0ee636556c162439d4d54c974a65253357c"
const Sha256_deploy_internal_configmap_postgres_initdb_yaml = "0fb7b894ad36558db863698237cfb55b7908c40ee6286db110f6c97c9f362717"

const File_deploy_internal_configmap_postgres_initdb_yaml = `apiVersion: v1
kind: ConfigMap
Expand Down Expand Up @@ -3653,6 +3661,37 @@ data:
-e 's/^pg_ctl\sstart.*/pg_ctl start || true/' \
/usr/bin/run-postgresql
su postgres -c "bash -x /usr/bin/run-postgresql"
dumpdb.sh: |
set -e
sed -i -e 's/^\(postgres:[^:]\):[0-9]*:[0-9]*:/\1:10001:0:/' /etc/passwd
su postgres -c "bash -x /usr/bin/run-postgresql" &
until pg_isready; do sleep 1; done;
pg_dumpall -U postgres > /$HOME/data/dump.sql
exit 0
upgradedb.sh: |
set -e
PGDATA=$HOME/data/userdata
PGDATA_new=$HOME/data/userdata-new
mv $PGDATA $PGDATA_new
sed -i -e 's/^\(postgres:[^:]\):[0-9]*:[0-9]*:/\1:10001:0:/' /etc/passwd
su postgres -c "bash -x /usr/bin/run-postgresql" &
until pg_isready; do sleep 1; done;
psql -U postgres < /$HOME/data/dump.sql
rm /$HOME/data/dump.sql
rm -rf $PGDATA_new
exit 0
revertdb.sh: |
PGDATA=$HOME/data/userdata
PGDATA_new=$HOME/data/userdata-new
if [ -d $PGDATA_new ]; then
rm -rf $PGDATA
mv $PGDATA_new $PGDATA
fi
exit 0
`

const Sha256_deploy_internal_deployment_endpoint_yaml = "bdbc90cf86e4b67acccc7e7413522d46dacf1c2d04d1d5d5e823a2b45e5c9b97"
Expand Down
4 changes: 2 additions & 2 deletions pkg/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ var OperatorImage = "noobaa/noobaa-operator:" + version.Version
var CosiSideCarImage = "gcr.io/k8s-staging-sig-storage/objectstorage-sidecar/objectstorage-sidecar:v20221117-v0.1.0-22-g0e67387"

// NooBaaImage is the container image url built from https://github.com/noobaa/noobaa-core
// it can be overridden for testing or different registry locations.
// it can be overridden for testing or dgraifferent registry locations.
var NooBaaImage = ContainerImage

// DBImage is the default db image url
Expand All @@ -76,7 +76,7 @@ var DBImage = "centos/mongodb-36-centos7"

// DBPostgresImage is the default postgres db image url
// currently it can not be overridden.
var DBPostgresImage = "centos/postgresql-12-centos7"
var DBPostgresImage = "quay.io/sclorg/postgresql-15-c8s"

// DBMongoImage is the default mongo db image url
// this is used during migration to solve issues where mongo STS referencing to postgres image
Expand Down
Loading

0 comments on commit 54cac98

Please sign in to comment.