fleet uses a declarative model to evaluate unit state. This means that operations to change the state of units (e.g.
fleetctl commands, or calls to the fleet API) change the desired state, rather than directly performing any state change. There are currently three cluster-level states for a unit:
inactive: known by fleet, but not assigned to a machine
loaded: assigned to a machine and loaded into systemd there, but not started
launched: loaded into systemd, and fleet has called the equivalent of
Units may only transition directly between these states. For example, for a unit to transition from
launched it must first go state
The desired and last known states are exposed in the
STATE columns of the output from
fleetctl commands to act on units change the desired state of a unit. fleet itself is then responsible for performing the necessary state transitions to move a unit to the desired state. The following table explains the relationship between each
fleetctl command and unit states.
|Command||Description||Desired State||Valid Previous States||Is an alias for|
||Submits unit file into etcd registry||
||Submits and schedules unit file into machines' systemd but doesn't start it||
||Submits, schedules and starts unit file||
||Stops scheduled unit file||
||Stops and unschedules unit file from machines' systemd||
||Stops, unschedules and removes unit file from etcd registry||
none indicates that the unit has not yet been submitted to fleet at all (or it previously existed in fleet but was destroyed).
fleetctl startwill cause it to be
fleetctl destroywill cause it to be
fleetctl stopis an invalid action
The other state associated with units in fleet is their systemd unit state. This will only exist for units which are assigned to a machine and known by systemd on that machine; i.e., they are in state
The systemd state is composed of three subcomponents, exposed in
fleetctl list-units. fleet retrieves this state directly from systemd and performs no manipulation before presenting it to the user; they correspond exactly to the respective output columns from the
systemctl list-units command.
LOAD(reflects whether the unit definition was properly loaded)
ACTIVE(the high-level unit activation state, i.e. generalization of SUB)
SUB(the low-level unit activation state, values depend on unit type)
By default, only the
SUB unit states are exposed by