Worker

See first: Juju | Worker

In Juju, a worker is any type that implements the worker interface.

Examples of workers include the dependency engine, instances run by the dependency engine (the typical usage of the term “worker”), and watchers.

Note: A Juju agent runs one or more workers at the same time in parallel. A worker may run / be run by another worker.

List of workers run by the dependency engine

In Juju, the term “worker” is most commonly used to denote types whose instances are run by the dependency engine. These types are defined by the worker packages listeds below.

The most important workers to know about are: the uniter, the deployer, the provisioner, and the caasapplicationprovisioner, the charmdownloader, and the undertaker.

agent

agentconfigupdater

apiaddressupdater

The apiaddressupdater worker watches and stores the controllers’ addresses.

apicaller

apiconfigwatcher

apiserver

apiservercertwatcher

applicationscaler

auditconfigupdater

authenticationworker

caasadmission

caasapplicationprovisioner

The caasapplicationprovisioner worker is actually two workers:

  • provisioner: Watches a Kubernetes model and starts a new worker of the appWorker type whenever an application is created.

  • appWorker: Drives the Kubernetes provider to create, manage, and destroy Kubernetes resources to match a requested state. Also writes the state of created resources (application/unit status, application/unit IP addresses & ports, filesystem info, etc.) back into the database.

caasbroker

caasenvironupgrader

caasfirewaller

caasfirewallersidecar

caasmodelconfigmanager

caasmodeloperator

caasoperator

caasoperatorprovisioner

caasprober

caasrbacmapper

caasunitprovisioner

caasunitsmanager

caasunitterminationworker

caasupgrader

centralhub

certupdater

changestream

charmdownloader

charmrevision

The charm revision updater worker is responsible for polling Charmhub every 24 hours to check if there are new revisions available of any repository charm deployed in the model. If so, it will put a document in the Juju database, so that the next time the user runs juju status they can see that there is an update available. This worker also sends anonymised usage metrics to Charmhub when it polls.

This worker doesn’t contain much business logic - most of the work is delegated to the facade call.

cleaner

The cleaner worker handles database clean-up events.

common

containerbroker

The containerbroker worker’s sole responsibility is to manage the lifecycle of an instance-broker. Configuration of the instance-broker relies on talking to the provisioner to ensure that we correctly configure the correct availability zones. Failure to do so, will result in an error.

The instance-broker is created for LXD types only – any other container types cause the worker to uninstall itself.

controllerport

credentialvalidator

dbaccessor

deployer

diskmanager

The diskmanager worker periodically lists block devices on the machine it runs on.

This worker will be run on all Juju-managed machines (one per machine agent).

environ

environupgrader

externalcontrollerupdater

fanconfigurer

filenotifywatcher

firewaller

The firewaller worker modifies provider networks when a user exposes/de-exposes applications, or when a unit closes/opens ports.

fortress

The fortress worker implements a convenient metaphor for an RWLock.

A “fortress” is constructed via a manifold’s Start func, and accessed via its Output func as either a Guard or a Guest. To begin with, it’s considered to be locked, and inaccessible to Guests; when the Guard Unlocks it, the Guests can Visit it until the Guard calls Lockdown. At that point, new Visits are blocked, and existing Visits are allowed to complete; the Lockdown returns once all Guests’ Visits have completed.

The original motivating use case was for a component to mediate charm directory access between the uniter and the metrics collector. The metrics collector must be free to run its own independent hooks while the uniter is active; but metrics hooks and charm upgrades cannot be allowed to tread on one another’s toes.

gate

The gate worker provides a mechanism by which independent workers can wait for one another to finish a task, without introducing explicit dependencies between those workers.

See more: juju/worker/gate

hostkeyreporter

httpserver

httpserverargs

identityfilewriter

instancemutater

Package instancemutater defines workers that compare the list of lxd profiles applied to a machine with the list of expected profiles based on the application versions which should be running on the machine. In particular, it creates two workers from the same code with different configurations; the ContainerWorker and the EnvironWorker.

The ContainerWorker runs on a machine and watches for containers to be created on it.

    	┌──────────────────────────────┐
    	│       MACHINE                │
    	│                              │
    	│                              │
    	│   ┌─────────────────────┐    │
    	│   │                     │    │
    	│   │     CONTAINER       │    │
  ┌────┼───►                      │    │
  │    │   │                      │    │
  │    │   │  ┌────────────────┐  │    │
  │    │   │  │   UNIT         │  │    │
  │    │   │  │                │  │    │
  │    │   │  │                │  │    │
  │    │   │  │ ┌────────────┐ │  │    │
  │    │   │  │ │ CHARM      │ │  │    │
  │    │   │  │ │            │ │  │    │
  │    │   │  │ └─────┬──────┘ │  │    │
  │    │   │  │       │        │  │    │
  │    │   │  └───────┼────────┘  │    │
  │    │   │          │           │    │
  │    │   └──────────┼───────────┘    │
  │    │              │                │
  │    └──────────────┼────────────────┘
  │                   │
  └───────────────────┘
LXD PROFILE

The EnvironWorker watches for machines in the model to be created.

  	┌─────────────────────────────────┐
  	│       MACHINE                   │
  	│                                 │
 ┌────►                               │
 │    │   ┌──────────────────────┐    │
 │    │   │                      │    │
 │    │   │     CONTAINER        │    │
 │    │   │                      │    │
 │    │   │                      │    │
 │    │   │  ┌────────────────┐  │    │
 │    │   │  │   UNIT         │  │    │
 │    │   │  │                │  │    │
 │    │   │  │                │  │    │
 │    │   │  │ ┌────────────┐ │  │    │
 │    │   │  │ │ CHARM      │ │  │    │
 │    │   │  │ │            │ │  │    │
 │    │   │  │ └─────┬──────┘ │  │    │
 │    │   │  │       │        │  │    │
 │    │   │  └───────┼────────┘  │    │
 │    │   │          │           │    │
 │    │   └──────────┼───────────┘    │
 │    │              │                │
 │    └──────────────┼────────────────┘
 │                   │
 └───────────────────┘

LXD PROFILE

To understand this better with a similar mechanism, take a look at the provisioner worker as well.

instancepoller

The instancepoller worker updates network addresses and any related information for providers.

introspection

leadership

lease

Package lease, also known as “the manager”, manages the leases used by individual Juju workers.

Workers will claim a lease, and they are either attributed (i.e., the workers gets the lease ) or blocked (i.e., the worker is waiting for a lease to become available). In the latter case, the manager will keep track of all the blocked claims. When a worker’s lease expires or gets revoked, then the manager will re-attribute it to one of other workers, thus unblocking them and satisfying their claim.

In the special case where a worker is upgrading an application, it will ask the manager to “pin” the lease. This means that the lease will not expire or be revoked during the upgrade, and the validity of the lease will get refreshed once the upgrade has completed. The overall effect is that the application unit does not lose leadership during an upgrade.

leaseexpiry

lifeflag

logforwarder

logger

The logger worker watches the local logger configuration and reconfigures it when needed.

logsender

machineactions

machiner

The machiner worker terminates the agent when the machine has a fatal error.

machineundertaker

meterstatus

The meterstatus worker executes the meter-status-changed hook periodically.

metrics

metricworker

migrationflag

migrationmaster

migrationminion

minunitsworker

mocks

The mocks worker contains common worker mocks.

Run go generate to regenerate the mock interfaces.

modelcache

modelworkermanager

multiwatcher

The multiwatcher worker provides watchers that watch the entire model.

It is responsible for creating, feeding, and cleaning up after multiwatchers.

The core worker gets an event stream from an AllWatcherBacking, and manages the multiwatcher Store.

The behaviour of the multiwatchers is very much tied to the Store implementation. The store provides a mechanism to get changes over time.

muxhttpserver

peergrouper

The peergrouper worker maintains the MongoDB replica set.

presence

provisioner

The provisioner worker watches LXC and KVM instances, and provisions and decommissions them when needed.

proxyupdater

pruner

pubsub

querylogger

reboot

remoterelations

Package remoterelations defines workers which manage the operation of cross model relations.

  • Worker: Top level worker. Watches SaaS applications/proxies and creates a worker for each.

  • remoteApplicationWorker: Manages operations for a consumer or offer proxy. Consumes and publishes relation data and status changes.

  • remoteRelationsWorker: Runs on the consuming model to manage relations to the offer.

  • relationUnitsWorker: Runs on the consuming model to receive and publish changes to each relation unit data bag.

The consuming side pushes relation updates from the consumer application to the model containing the offer. It also polls the offered application to record relation changes from the offer into the consuming model.

retrystrategy

s3caller

secretbackendrotate

The secretbackendrotate worker tracks and rotates a secret backend token.

secretdrainworker

The secretdrainworker runs on the agent and drains secrets to the new active backend when the model changes secret backends.

secretexpire

The secretexpire worker tracks and notifies when a secret revision should expire.

secretrotate

The secretrotate worker tracks a secret and notifies when it should be rotated.

simplesignalhandler

The simplesignalhandler worker responds to OS signals and returns a pre-defined error from this worker when the signal is received.

singular

state

stateconfigwatcher

stateconverter

storageprovisioner

The storageprovisioner worker manages the provisioning and deprovisioning of storage volumes and filesystems,attaching them to and detaching them from machines.

A storageprovisioner worker is run at each model manager, which manages model-scoped storage such as virtual disk services of the cloud provider. In addition to this, each machine agent runs a machine storageprovisioner worker that manages storage scoped to that machine, such as loop devices, temporary filesystems (tmpfs), and rootfs.

The storageprovisioner worker consists of the following major components:

  • a set of watchers for provisioning and attachment events

  • a schedule of pending operations

  • event-handling code fed by the watcher, that identifies interesting changes (unprovisioned -> provisioned, etc.), ensures prerequisites are met (e.g. volume and machine are both provisioned before attachment is attempted), and populates operations into the schedule

  • operation execution code fed by the schedule, that groups operations to make bulk calls to storage providers; updates status; and reschedules operations upon failure

syslogger

terminationworker

The terminationworker stops the agent when it has been signalled to do so.

toolsversionchecker

undertaker

unitassigner

uniter

The uniter worker implements the capabilities of the unit agent, for example running a charm’s hooks in response to model events. The uniter worker sets up the various components which make that happen and then runs the top level event loop.

upgradedatabase

upgrader

The upgrader worker schedules upgrades of the agent’s binary, i.e. it upgrades the agent itself.

upgradeseries

upgradesteps