Skip to main content
Version: 3.1

Upgrading from 3.0 to 3.1

Move a 3.0 installation to 3.1: get 3.1, check, stop, back up and run upgrade apply once, then start. Buffered messages come through the upgrade.

From
3.0.0
Installs
Docker Compose · docker run · Single binary · Helm
Upgrade step
upgrade apply, once

3.1 is a minor release. It is not a swap of the image tag: 3.1 stores some of your data differently from 3.0, so your data is migrated once, by a command you run. MaestroHub never migrates data on its own. If you start 3.1 without the command, it refuses to start and tells you why (see If you skip the step).

What the command changes in 3.0 data:

  • Store and forward: the buffers' records get a version, and buffers that kept the old 24-hour default retention move to keep until delivered (see What changes in 3.1).
  • Access: role grants are moved to their 3.1 form.
  • Database: the new tables and columns of 3.1 are added.

upgrade check lists each of these for your own data before anything is changed.

The steps​

StepWhat you doMaestroHub is
1Get 3.1Running on 3.0
2upgrade checkRunning on 3.0
3Stop MaestroHubStopped
4Back up, then upgrade applyStopped
5Start 3.1Running on 3.1

MaestroHub is stopped from step 3 to step 5. On a test installation with its stores in PostgreSQL, that took about a minute.

Is this guide for you?​

You runWhat to do
3.0.0Follow this guide.
3.0.0 with Docker Compose that a tool manages, such as Dokploy, Portainer or CoolifyFollow this guide, and read If a tool manages your Compose file first.
2.6.xFollow Upgrade from 2.6.x to 3.0 with the 3.1 image or archive. It runs the 3.1 upgrade in the same upgrade apply. Read What changes in 3.1 too.
No existing dataInstall 3.1. There is nothing to upgrade.

Which version do you run? Ask MaestroHub, without signing in:

curl http://localhost:8080/api/v1/version

It prints, for example, {"version":"3.0.0",…}.

Before you start​

  1. Read What changes in 3.1. Most of it is store and forward.
  2. Back up your PostgreSQL databases, if MaestroHub keeps stores in PostgreSQL (the single-node bundle does, and so does Helm). upgrade apply backs up MaestroHub's own file stores, not your databases. It asks for the name of your snapshot and refuses without one.
  3. Plan a short stop. While MaestroHub is stopped it reads nothing from your devices and sends nothing. Values your devices produce in that time are not buffered. Messages that were already buffered stay buffered (see below).

An outage in progress is fine. If a destination is down and MaestroHub is holding a backlog for it, upgrade anyway. In our customer-twin test, a Kafka link was cut on 3.0.0, the backlog built up, MaestroHub was upgraded to 3.1 during the cut, and 3.1 started with 7,598 messages still held. When the link came back, every one of them reached Kafka. The upgrade lost nothing and duplicated nothing.

Know your installation​

Each step below gives its commands once for each kind of installation. Answer these questions now, so you pick the right commands and change them where yours differs. Do not run any upgrade command yet: you run them from step 2 on, after step 1 has got 3.1.

  1. How do you run MaestroHub? In each step, use the tab that matches: Docker Compose, docker run, Single binary or Helm. If a tool such as Dokploy, Portainer or Coolify manages your Compose file, use the docker run tab, and read If a tool manages your Compose file.

  2. Does MaestroHub run with a config file? Look at the MaestroHub service in your Compose file, or at the command you start MaestroHub with. An installation upgraded from 2.6 often still has its 2.6 Compose file.

    You seeThen
    A command: line, or a start command, with --config <file>Use the commands under With a config file, with your own file. With docker run or the single binary, pass the same --config <file> to every command; with docker run, mount the file too.
    No command: line and no --configUse the commands under Without a config file, or leave out --config. MaestroHub runs with its default settings and has no config file.

    A --config that names a file your installation does not have stops the command with failed to read config file: open /config/config.yaml: no such file or directory.

  3. What is your service called? The Compose commands use the service name maestrohub, as in the 3.0 bundles. docker compose config --services lists yours: use it in place of maestrohub. Run every Compose command from the folder that holds your Compose file.

  4. What is your data volume called? The docker run commands use the volume maestrohub-data. Use the volume name you gave 3.0 in its place.

  5. Is the disk that holds Docker's data small? upgrade check copies your stores there. See Free space for the copies in step 2.

If a tool manages your Compose file​

Tools such as Dokploy, Portainer and Coolify keep the Compose file in their own records, and write it to the host again at every deploy. Two things follow:

  • A change to the Compose file on the host does not last. The tool's next deploy writes its own version over it. The tool can also recreate the folder that holds the file, and a shell still in that folder then fails with getwd: no such file or directory.
  • A deploy with the 3.1 image before step 4 starts 3.1 on 3.0 data. It changes nothing, but MaestroHub refuses to start (see If you skip the step) and stays down until you finish steps 3 and 4.

So run steps 1 to 4 with the docker run commands, from any folder outside the tool's (your home folder, for example). They name the 3.1 image themselves, so the tool's Compose file stays on 3.0 and MaestroHub keeps running until step 3. Change the image in the tool only in step 5.

The docker run commands need the names your tool gave the container and the data volume. These two commands only read, so run them now:

  1. Find the MaestroHub container's name:

    docker ps --format '{{.Names}}  {{.Image}}'
  2. Find its data. Put the container's name from the first command in place of maestrohub:

    docker inspect maestrohub --format '{{range .Mounts}}{{println .Destination .Name .Source}}{{end}}'

    Use the line that starts with /data. If it has three words, the second is the volume's name: use it in place of maestrohub-data in every command. If it has two, the data is a folder on the host and the second word is its path: use that path in place of maestrohub-data.

If the service in the tool's Compose file has a command: line with --config <file>, mount that file and pass the same --config too.

Step 1. Get 3.1​

Keep a copy of your Compose file and .env, then set the image tag to 3.1.0 (in image: or in your .env) and pull it:

docker compose pull maestrohub

Do not run docker compose up yet. 3.0 keeps running until step 3.

Step 2. Check​

upgrade check changes nothing and is safe while 3.0 runs. It works on copies of your stores and reports what apply would do.

Free space for the copies. check copies the stores it upgrades to a temporary folder, and deletes the copies when it ends. In a container that folder is inside the container, on the disk that holds Docker's data (often /var/lib/docker). If that disk has less free space than your stores take (a large audit store, for example), put the copies on a larger disk with --work-dir. The folder must be writable by user ID 1000, which the upgrade runs as:

mkdir -p /mnt/big/upgrade-work && chown 1000:1000 /mnt/big/upgrade-work
docker run --rm -v maestrohub-data:/data -v /mnt/big/upgrade-work:/work \
maestrohub/context-platform:3.1.0 upgrade check --work-dir /work

With Docker Compose, add the same -v /mnt/big/upgrade-work:/work after run --rm, and --work-dir /work at the end.

With a config file (your service has a command: line with --config):

docker compose run --rm maestrohub upgrade check --config /config/config.yaml

Without a config file (your service has no command: line):

docker compose run --rm maestrohub upgrade check

Exit code 2 with work listed is what you expect from 3.0 data. If it lists an item that needs a person, read it now: apply asks you about it.

If it stops with failed to read config file: … no such file or directory, the command names a config file your installation does not have: it runs with the default settings. Run it again without --config /config/config.yaml: docker compose run --rm maestrohub upgrade check. See Know your installation.

Step 3. Stop MaestroHub​

docker compose stop maestrohub

Step 4. Back up and apply​

Take your PostgreSQL snapshot first, if you keep stores there. Then run apply. It asks what it needs to know, backs up every file store it changes, migrates your data and verifies the result. If a step fails, it puts every store back as it was.

With a config file (your service has a command: line with --config):

docker compose run --rm maestrohub upgrade apply --config /config/config.yaml

Without a config file (your service has no command: line):

docker compose run --rm maestrohub upgrade apply

With stores in PostgreSQL, add --db-snapshot-taken <your snapshot name>.

It ends with Upgraded and verified, and a To undo command that takes you back to 3.0 until 3.1 has started: keep it.

The commands that check and apply print, such as Next and To undo, are always in the Docker Compose form. With docker run, keep everything from upgrade on, and put your docker run prefix in front of it.

In a script, give --force --data-not-in-use so it does not ask, and --db-snapshot-taken <name> for PostgreSQL. The flags are in the command reference.

Step 5. Start 3.1​

docker compose up -d maestrohub
docker compose ps maestrohub

The container shows healthy once 3.1 is ready.

Buffers that held messages before the upgrade show them on Store & Forward, and deliver them once their destination answers.

Helm​

Single-node chart. Every helm upgrade (and every Argo CD sync) first runs the <release>-upgrade-gate Job: upgrade check in the new image, read-only. On 3.0 data it fails the release with exit code 2, so the running 3.0 pod keeps serving instead of being replaced by one that cannot start. Read its report:

kubectl -n <namespace> logs job/<release>-upgrade-gate

Then:

  1. Take a snapshot of the PostgreSQL databases.
  2. Scale the app to 0 (with Argo CD, turn auto-sync off first).
  3. Run context-platform upgrade apply --config /config/config.yaml --force --data-not-in-use --db-snapshot-taken <name> once, in a pod with the app's image, config, secret and data volume.
  4. Upgrade (or sync) again. The gate passes and 3.1 starts.

The chart's README.md (section Upgrade gate) has the commands for each step.

--reuse-values works. A 3.0.0 release upgraded with helm upgrade --reuse-values is no longer refused for engine.durability.storeLimitBytes. The chart now derives the store-and-forward limit from nats.config.jetstream.fileStore.maxSize. A value carried over from 3.0 that differs from it is refused, with the fix: --set engine.durability.storeLimitBytes=0. Keep the value only with an external NATS.

Enterprise chart (one deployment per service). helm upgrade runs the data upgrade for you, in the <release>-upgrade Job, before any 3.1 service starts. You take the database snapshot and give its name; the Job does steps 2 to 5.

  1. Run the upgrade as you always do. Give it time, since Helm waits for the Job:

    helm upgrade <release> <3.1 chart> -n <namespace> -f <your values> --timeout 30m

    The Job runs upgrade check against every MaestroHub database. On 3.0 data it stops the upgrade with nothing deployed, and 3.0 keeps running. Its log lists what 3.1 converts in your data, and how to take the snapshot:

    kubectl -n <app namespace> logs job/<release>-upgrade --all-containers
  2. Take a snapshot of the MaestroHub databases on your PostgreSQL server with your own tooling: a CloudNativePG backup, a volume snapshot, or pg_dump of each database. With backup.postgres.enabled, the chart's backup job takes one now. The log prints the command with your names; for a release named maestrohub it is:

    kubectl -n maestrohub create job --from=cronjob/maestrohub-backup-postgres pre-3-1
  3. Run the same upgrade again with the snapshot's name:

    helm upgrade <release> <3.1 chart> -n <namespace> -f <your values> --timeout 30m \
    --set upgrade.snapshotTaken=<snapshot name>

    The Job stops every MaestroHub service of the release (the databases keep running), runs upgrade apply, and prints what it converted. Then Helm starts the 3.1 services. MaestroHub is stopped from the start of upgrade apply until the 3.1 services are ready. On a test installation of nine services, the whole helm upgrade took under 30 seconds.

Running the upgrade again later is safe: with nothing left to convert, the Job stops nothing and the upgrade goes on. You can leave upgrade.snapshotTaken in your values.

  • The image. The Job runs one image, maestrohub/context-platform at the chart's version. It carries the upgrade command, and it also stops the services, through the Kubernetes API with the Job's own service account. If your chart's version is not the version of your services, set upgrade.image.tag to the 3.1 version.
  • Documents that need a person. If the log says a document needs a person, read its finding, then add --set upgrade.accept={<id>,<id>}.
  • If upgrade apply fails, the log says what was changed and what was put back. MaestroHub stays stopped. helm rollback <release> starts 3.0 again. If the report says a database was left changed, restore your snapshot first.
  • Argo CD runs the Job as a PreSync hook. The sync fails on 3.0 data until you set upgrade.snapshotTaken in the Application's values.

The chart's README.md (values upgrade.*) describes each setting.

Air-gapped installs. The upgrade Job needs one image besides the 3.1 service images you already mirror: MaestroHub's own maestrohub/context-platform, at the version you install. Nothing else is pulled.

  1. Copy it into your registry, from a machine that reaches Docker Hub and your registry:

    docker pull maestrohub/context-platform:3.1.0
    docker tag maestrohub/context-platform:3.1.0 registry.example.com/maestrohub/context-platform:3.1.0
    docker push registry.example.com/maestrohub/context-platform:3.1.0
  2. Point the Job at it in your values. If your registry needs credentials, the Job uses the same pull secret as the rest of the chart, global.imagePullSecrets:

    upgrade:
    image:
    repository: registry.example.com/maestrohub/context-platform
    tag: "3.1.0"
    pullPolicy: IfNotPresent
    global:
    imagePullSecrets:
    - name: my-registry-credentials
  3. Run the steps above. To see which image the Job will run before you upgrade, render it:

    helm template <release> <3.1 chart> -f <your values> --show-only templates/job-upgrade.yaml | grep image:

If you skip the step​

If you start 3.1 on 3.0 data without upgrade apply, nothing is changed and nothing runs:

  • MaestroHub prints what it found and the commands to run, and serves a Data migration needed page on its address.
  • Docker shows the container unhealthy. docker inspect shows why: the health check prints MaestroHub did not start and the command to run.
  • Kubernetes keeps the pod running and not ready (/ready answers 503 with the reason).
  • Helm refuses the release at the upgrade gate, or on the Enterprise chart at the upgrade Job (see above).

Stop it, then go on from step 3. See also 3.0 was started before the upgrade.

If you want to go back​

Until 3.1 has started on your data, upgrade restore puts back the backup that apply took. Restore your PostgreSQL snapshot as well, then start 3.0 again. See Upgrade problems.