Upgrading a machine's series

Upgrading the operating system running on each of the machines is a multi-step process. Each of the machines operating systems must be upgraded, then each of the charms.

Juju uses the term “series” to refer to the OS release. Ubuntu OS releases are currently referred to via their codenames, whilst other OS (Windows, Centos and MacOS) use their official names.

Page contents

Upgrading an models series

To upgrade an existing models series, so that any new additional deployment gets the new series will require changing the default-series of the model.

juju model-config -m <model> default-series=<series>

Upgrading an application series

To upgrade an application’s series, Juju first needs to upgrade each individual machine hosting the application units. Likewise, to upgrade a model’s series, perform the upgrade steps on each of its machines.

Upgrading a machine's series

Upgrade-series allows users to perform a managed upgrade of the underlying operating system of the machine. The upgrade is broken down into two steps; prepare and complete.

The upgrading of the machine is a manual process and the commands notify Juju the step at which the upgrade is in.

The “prepare” step notifies Juju that a series upgrade is taking place for a given machine and as such Juju guards that machine against operations that would interfere with the upgrade process.

The “complete” step notifies juju that the managed upgrade has been successfully completed.

It should be noted that once the prepare command is issued there is no way to
cancel or abort the process. Once you commit to prepare you must complete the
process or you will end up with an unusable machine!

An overview of the series upgrade process:

  1. The user initiates the upgrade.
    1. The machine is no longer available for charm deployments or for hosting new containers.
    2. Juju prepares the machine for the upcoming OS upgrade.
    3. All units on the machine are taken into account.
  2. The user manually performs the upgrade of the operating system and makes any other necessary changes. This should be accompanied by a maintenance window managed by the user.
  3. The user informs Juju that the machine has been successfully upgraded. The machine becomes available for charm deployments.

At no time does Juju take any action to prevent the machine from servicing workload client requests.


Clustered application?: If your application relies on maintaining a quorum of a minimum number of nodes, add more units before running juju upgrade-series.

Example

Let’s start with a base model that deploys AMQP implementation RabbitMQ with the rabbitmq-server charm.

$ juju add-model testing
$ juju deploy rabbitmq-server -n 3 --series xenial
$ juju config rabbitmq-server min-cluster-size=3

Preparation

As RabbitMQ will cease to function if one of its nodes becomes unavailable due to an upgrade, we can temporarily add more capacity:

$ juju add-unit -n 2 rabbitmq-server

Initiate upgrade series

Now we indicate to Juju that we’re intending on upgrading the series of the machines.

$ juju upgrade-series 0 prepare bionic
WARNING: This command will mark machine "0" as being upgraded to series "bionic".
This operation cannot be reverted or canceled once started.
Units running on the machine will also be upgraded. These units include:
  rabbitmq-server/0

Leadership for the following applications will be pinned and not
subject to change until the "complete" command is run:
  rabbitmq-server

Continue [y/N]? y

Answering y at this point initiates the upgrade process.

machine-0 started upgrade series from "xenial" to "bionic"
rabbitmq-server/0 pre-series-upgrade hook running
rabbitmq-server/0 pre-series-upgrade completed
machine-0 binaries and service files written

Juju is now ready for the series to be updated.
Perform any manual steps required along with "do-release-upgrade".
When ready, run the following to complete the upgrade series process:

juju upgrade-series 0 complete

Upgrading the operating system

One important step in upgrading the operating system is the upgrade of all software packages. To do this on Ubuntu-based machines, log in to the machine via SSH and execute the do-release-upgrade command:

juju ssh 0
$ do-release-upgrade

This step typically requires interaction. The upgrade process may need assistance to indicate how to handle changed configuration files, for example.

Mark the series upgrade as complete

Juju now needs to run the “complete” phase of the upgrade-series command. This gives charms the chance to execute any code that they need to when the operating system changes.

juju upgrade-series 0 complete

Repeat steps for other machines

Upgrade the series of any other machines. In this example, machines 1 and 2 require upgrading.

Remove any units needed for upgrade

If necessary, remove any units created to maintain a quorum should be removed:

juju remove-unit rabbitmq-server/3
juju remove-unit rabbitmq-server/4

Upgrading a controller machine

To “upgrade” the series of a controller, create a new controller using the preferred series then migrate to it and delete the old controller:

Create a new controller

Create the new controller with the juju bootstrap command. Here, we’re using AWS and have called the new controller ‘aws-new’:

juju bootstrap aws aws-new --bootstrap-series=<series>

Migrate models to the new controller

Now migrate your existing models by following the Migrating models page.

To ensure that all new machines will run the new series (like the controller, we’ll use ‘bionic’) set the default series at the model level. For each migrated model:

juju model-config -m <model name> default-series=<series>

Destroy the old controller

Destroy the old controller when done:

juju destroy-controller aws-old

The section regarding Upgrading an application’s is not very clear I find. I think it is clear that existing machines will need to be upgrading manually, but I wanted to upgrade the series of an application so new units would use Focal. The wording made it sound like upgrading each machine of a certain application would also set the series flag for future units that are added. However, this is not the case. To set the series for an application the command is:
juju set-series <application> <series>

1 Like

perhaps this is not the right place but… how do I update/upgrade apt packages of a juju controlled machine ? I have maybe 5-6 custom charms and trying to find the most “juju” way of giving myself and my team an easy way to juju update&upgrade --all within a controller or model space

1 Like

I would likely implement an action for this.

1 Like