See also: Juju OLM | Agent

In Juju, all the tasks that a Juju agent performs are handled by Juju workers. The term task is therefore sometimes used as synonymous to a worker. Each worker performs a single task at a time in a single thread. A Juju agent runs one or more workers at the same time in parallel.

There are three types of workers:

  1. Machine Worker : These workers run in a Machine Agent. Their typical tasks are related with:
  • Unit deployment,
  • Model management, or
  • A generic machine task.

  1. Unit worker : This worker runs in a Unit Agent when the Unit runs in Kubernetes, or in a Machine Agent when the Unit is deployed on a different type of substrate. There exists a single worker per deployed unit.

  2. Controller workers : These workers run in a Controller Agent, and perform various tasks related with the controller.

Machine, unit, and controller agents have some common worker types:

  • Upgrader : Schedules upgrade of the agent’s binary, i.e. it upgrades the agent itself,
  • Logger : Watches the local logger configuration and reconfigures it when needed,
  • API Address Updater : Watches and stores the controllers’ addresses.

Besides these common worker types, there are specific ones that each agent type runs. The following sections of this page provide more detail.


Machine workers

Machine workers run in a machine agent. For example, each machine agent runs a deployer worker, which watches for any units that have been assigned to the machine. It runs each unit’s workers in the unit’s own runner. Besides the deployer worker, some worker types are only found in a machine agent:

  • Upgrader : A worker that runs an upgraded code binary once the old binary has been replaced,
  • Termination worker : Stops the agent when it has been signalled to do so,
  • Machiner : Terminated the agent when the machine has a fatal error,
  • Machine Environment Worker : Watches proxy configuration and reconfigures the machine,
  • Provisioner : Watches LXC and KVM instances, and provisions and decommissions them when needed.

Unit workers

A unit worker, is a state-machine that manages a unit’s workload operations in a unit agent. It is single-threaded, and runs a sequence of functions called modes.

There are two fundamental components of a unit worker:

  1. Filter : Talks to the API server and the outside world to deliver relevant events to modes,
  2. Uniter : Exposes a number of methods that can be called by the modes.

A unit worker is often simply referred to as a uniter.

Controller workers

As the name implies, control workers run at a Juju controller agent. In essence, a Juju controller agent is a machine agent with extra responsibilities, which can be listed as follows:

  • A worker that runs the controller API server,
  • Provisioner : Provision and decommission instances when needed,
  • Firewaller : Modifies provider networks when a user exposes/de-exposes applications, or when a unit closes/opens ports,
  • Instance poller : Updates network addresses and any related information for providers,
  • Cleaner : Handles database clean-up events,
  • Peer Grouper : Maintains the MongoDB replica set,
  • Resumer : Resumes incomplete MongoDB transactions.

Many Controller Agents are run in the same machine where the MongoDB replica-set master runs. When the master changes, these workers all stop.

Last updated 10 months ago.