Container-based schema upgrade¶
Warning
If the DB schema upgrade fails, there is no automated rollback to the previous schema. Rollback will involve some manual steps. Not all schema changes can be rolled back (for example, deleting columns or tables). Before upgrading a production database, it is strongly recommended to back up the DB and to execute the upgrade procedure against a clone of the DB before upgrading the production DB.
Warning
The container upgrade is currently only compatible with oracle databases. This documentation will be updated when support for other DBMS is added.
The procedure for the DB schema upgrade is described below. This is the procedure used at CERN to upgrade the catalogue schema in production and preproduction. For local development the upgrade should be done manually on ones machine. Before proceeding with the upgrade it is advised to read the CTA release notes as extra work may be necessary for certain catalogue upgrades.
Pull the container from the registry¶
The production
tag contains the most recent version of the container tested to work at CERN, and is the recomended tag.
Find gitlab registry credentials by running tbag
command on aiadm
:
$ tbag show --hg cta "gitlabregistry"
Go to the machine, that has access to the catalogue, and login to gitlab registry using the creadentials from previous step:
# podman login gitlab-registry.cern.ch
Pull the latest production image:
# podman pull gitlab-registry.cern.ch/cta/eoscta-operations/registry/container_registry/cta-catalogue-updater:production
8e51f5c9: Pulling from cta/eoscta-operations/registry/container_registry/cta-catalogue-updater
342eefc49a66: Pull complete
d14315fa4585: Pull complete
0e40c1a45658: Pull complete
4326a2ebd6be: Pull complete
17aa569b6eb9: Pull complete
aa23622d2fe5: Pull complete
Digest: sha256:3192f0b470130c4a14376b75a8a48a9df83a975a127432cf6c141d4a5b50954a
Status: Downloaded newer image for gitlab-registry.cern.ch/cta/eoscta-operations/registry/container_registry/cta-catalogue-updater:production
Execute the upgrade procedure¶
To perform the catalogue update, the container requires the cta-catalogue.conf
file to be mounted in the directory /shared/etc_cta
and the yum repos to download the cta RPMs to be mounted in the directory /shared/etc_yum.repos.d
.
The steps to container takes to perform the catalogue update are as follows:
- Install the necessary oracle rpms to connect to the database (namely
oracle-instantclient-tnsnames.ora.noarch
) - Install the cta-catalogueutils RPM to get access to the
cta-catalogue-schema-verify
command - Clone the CTA repo and checkout the version specified by the user to get access to the catalogue migration scripts.
- Run the
cta-catalogue-schema-verify
command to ensure the current catalogue schema is correct. - Perform the liquibase command the user specified (normally the
update
command, but can also use therollbackCount
command to rollback an update) - Run the
cta-catalogue-schema-verify
command to ensure the changes performed by liquibase left the catalogue with a correct schema.
The container requires the following command line arguments:
- -v
the version of CTA to checkout in step 3 - -f
the current version of the catalogue - -t
the version of the catalogue to upgrade to - -c
the liquibase command to run
The following command line arguments are optional:
- -d if specified, skip the schema verify steps 4 and 6.
- -s
Preflight command to run before step 4.
Example instantiation using podman:
podman run -it -v /etc/cta:/shared/etc_cta:ro -v /etc/yum-puppet.repos.d:/shared/etc_yum.repos.d:ro gitlab-registry.cern.ch/cta/eoscta-operations/registry/container_registry/cta-catalogue-updater:production -v 4.8.7-1 -f 12.0 -t 13.0 -c update