Managing Deployment Workflows

Workflows are automation process algorithms. They describe the flow of the automation by determining which tasks will be executed and when. A task may be an operation (implemented by a plugin), or other actions including running arbitrary code. Workflows are written in Python, using a dedicated framework and APIs.

Workflows are deployment-specific. Each deployment has its own set of workflows, which are declared in the Blueprint. Executions of a workflow are in the context of that deployment.

Controlling workflows (i.e. executing, cancelling, etc.) is achieved using REST calls to the management server. In this guide, the examples use Cloudify CLI commands, which in turn call the REST API calls.

Executing Workflows

Workflows can be executed directly. You can execute workflows from the CLI as follows:
cfy executions start my_workflow -d my_deployment

This executes the my_workflow workflow on the my_deployment deployment.

Workflows run on deployment-dedicated workers on the management server, on top of the Cloudify workflow engine.

When a workflow is executed, an execution object is created for the deployment, containing both static and dynamic information about the workflow’s execution run. The status field in the Execution object is an important dynamic field that conveys the current state of the execution.

An execution is considered to be a running execution until it reaches one of the three final statuses: terminated, failed or cancelled. For more information, see the Workflow Execution Statuses section on this page.

Queuing Executions

In general, executions run in parallel. There are a few exceptions:

If you start an execution and receive one of the following errors: “You cannot start an execution if there is a running system-wide execution” / “The following executions are currently running for this deployment…” / “You cannot start a system-wide execution if there are other executions running.”, you can add the execution to the executions queue:

Queued executions will begin automatically when possible.

Scheduling Executions

Cloudify allows the user to create schedules for running executions at specified times, both single-use and recurring. Execution schedules, also known as deployment schedules, belong to a specific deployment and can be created in two ways:

  1. By using the dedicated CLI command: cfy deployments schedule create
  2. By specifying under the deployment_settings section in a blueprint, the default schedules that should be created for any deployment based on this blueprint.

Each deployment schedule contains the following information, provided by the user: * Which workflow to run (e.g. install, uninstall etc.) * Execution arguments and additional parameters to be passed to the workflow
* since: the earliest time at which the workflow can run * until: the latest time at which the workflow can run * Scheduling parameters, either in human-readable format (recurrence frequency, on which weekdays to run, max. number of runs), or as an iCalendar RRULE

The schedules are then polled by the cloudify-execution-scheduler service, which runs continuously in the background. * Schedules are polled every 60 seconds, and those which have executions at the given time are run. * When the manager is in maintenance mode, the scheduler won’t run any executions. Executions scheduled for this time are skipped. * if polling and firing the scheduled executions to run takes more than 60 seconds, the scheduler will wait for the remainder of a whole minute to poll, so if an execution is scheduled to run every minute and takes e.g. 70 seconds to fire, it will actually run every 2 minutes.

Writing a Custom Workflow

If you are an advanced user, you might want to create custom workflows. For more information, see Creating Custom Workflows.