pallet.core.operations documentation

Built in operations

converge

fn

[compute groups service-state plan-state environment phases {:keys [targets execution-settings-f], :or {targets service-state, execution-settings-f (api/environment-execution-settings)}, :as options}]

Converge the groups, using the specified service-state to provide the existing nodes. The :bootstrap phase is run on new nodes. When tagging is supported the :bootstrap phase is run on those nodes without a :bootstrapped flag.

Options

:targets : used to restrict the nodes on which the phases are run to a subset of service-state. Defaults to service-state.

delay

fn

[delay units]
[delay]

Returns a delay fsm.

Options

:units : the units for the delay. A keyword from, :ns, :us, :ms, :s, :mins, :hours

lift

fn

[service-state plan-state environment phases {:keys [targets execution-settings-f phase-execution-f post-phase-f post-phase-fsm], :or {targets service-state, phase-execution-f (var primitives/build-and-execute-phase), execution-settings-f (api/environment-execution-settings)}}]

Lift nodes (targets which defaults to service-state), given a plan-state, environment and the phases to apply.

Options

:targets : used to restrict the nodes on which the phases are run to a subset of service-state. Defaults to service-state.

:phase-execution-f : specifies the function used to execute a phase on the targets. Defaults to pallet.core.primitives/build-and-execute-phase.

:post-phase-f : specifies an optional function that is run after a phase is applied. It is passed targets, phase and results arguments, and is called before any error checking is done. The return value is ignored, so this is for side affect only.

:post-phase-fsm : specifies an optional fsm returning function that is run after a phase is applied. It is passed targets, phase and results arguments, and is called before any error checking is done. The return value is ignored, so this is for side affect only.

:execution-settings-f : specifies a function that will be called with a node argument, and which should return a map with :user, :executor and :executor-status-fn keys.

lift-options

var

A sequence of keywords, listing the lift-options

lift-partitions

fn

[service-state plan-state environment phases {:keys [targets partition-f], :or {targets service-state}, :as options}]

Lift targets by phase, applying partitions for each phase.

To apply phases at finer than a group granularity (so for example, a :post-phase-f function is applied to nodes rather than a whole group), we can use partitioning.

The partitioning function takes a sequence of targets, and returns a sequence of sequences of targets. The function can filter targets as required.

For example, this can be used to implement a rolling restart, or a blue/green deploy.

Options

Options are as for lift, with the addition of:

:partition-f : a function that takes a sequence of targets, and returns a sequence of sequences of targets. Used to partition or filter the targets. Defaults to any :partition metadata on the phase, or no partitioning otherwise.

Other options as taken by lift.

node-count-adjuster

fn

[compute-service groups service-state plan-state environment targets execution-settings-f]

Adjusts node counts. Groups are expected to have node counts on them.

partition-targets

fn

[targets phase f]

Partition targets using the, possibly nil, default partitioning function f.

There are three sources of partitioning applied. The default passed to the function, a partioning based on the partitioning and post-phase functions in the target's metadata, and the target's partitioning function from the metadata.

The partitioning by metadata is applied so that post-phase functions are applied to the correct targets in lift.