RETIRED, further work has moved to Debian project infrastructure
Go to file
Renat Akhmerov 816bfd9dcc Refactor Mistral Engine
* Introduced class hierarchies Task and Action used by Mistral engine.
  Note: Action here is a different than executor Action and represents
  rather actions of different types: regular python action, ad-hoc
  action and workflow action (since for task action and workflow are
  polymorphic)
* Refactored task_handler.py and action_handler.py with Task and Action
  hierarchies
* Rebuilt a chain call so that the entire action processing would look
  like a chain of calls Action -> Task -> Workflow where each level
  knows only about the next level and can influence it (e.g. if adhoc
  action has failed due to YAQL error in 'output' transformer action
  itself fails its task)
* Refactored policies according to new object model
* Fixed some of the tests to match the idea of having two types of
  exceptions, MistralException and MistralError, where the latter
  is considered either a harsh environmental problem or a logical
  issue in the system itself so that it must not be handled anywhere
  in the code

TODO(in subsequent patches):
 * Refactor WithItemsTask w/o using with_items.py
 * Remove DB transaction in Scheduler when making a delayed call,
   helper policy methods like 'continue_workflow'
 * Refactor policies test so that workflow definitions live right
   in test methods
 * Refactor workflow_handler with Workflow abstraction
 * Get rid of RunExistingTask workflow command, it should be just
   one command with various properties
 * Refactor resume and rerun with Task abstraction (same way as
   other methods, e.g. on_action_complete())
 * Add error handling to all required places such as
   task_handler.continue_task()
 * More tests for error handling

P.S. This patch is very big but it was nearly impossible to split
it into multiple smaller patches just because how entangled everything
was in Mistral Engine.

Partially implements: blueprint mistral-engine-error-handling
Implements: blueprint mistral-action-result-processing-pipeline
Implements: blueprint mistral-refactor-task-handler
Closes-Bug: #1568909

Change-Id: I0668e695c60dde31efc690563fc891387d44d6ba
2016-05-31 14:08:36 +00:00
devstack Fix mistral installation in devstack 2016-05-11 14:14:20 +03:00
doc Fix the yaql github repository 2016-05-15 21:35:39 +05:30
etc Add config example for rotating logs 2015-08-25 02:04:38 +00:00
functionaltests Mistral tests will run from tempest plugin 2016-02-02 11:19:51 +00:00
mistral Refactor Mistral Engine 2016-05-31 14:08:36 +00:00
mistral_tempest_tests Refactor Mistral Engine 2016-05-31 14:08:36 +00:00
rally-jobs The Link for plugin samples is added 2015-09-08 05:21:03 +00:00
releasenotes Update reno for stable/mitaka 2016-03-17 08:52:54 +00:00
tools Add Designate apis as mistral actions 2016-05-16 02:54:41 -04:00
.coveragerc Change ignore-errors to ignore_errors 2015-09-21 16:24:47 +00:00
.gitignore module docs are not being generated 2016-03-21 17:27:14 -05:00
.gitreview Update .gitreview file for project rename 2015-06-12 23:12:30 +00:00
.mailmap .mailmap for pbr AUTHORS upate 2015-09-18 08:27:06 +00:00
.pylintrc Add .gitreview, setup.py and other infrastructure. 2013-11-01 02:57:27 +07:00
.testr.conf Move gate tests under mistral/tests 2014-08-15 11:14:59 +04:00
AUTHORS Add Designate apis as mistral actions 2016-05-16 02:54:41 -04:00
CONTRIBUTING.rst Add the CONTRIBUTING.rst file 2015-11-21 09:58:18 +05:30
docker_image_build.sh Fixed issue related to docker image creation 2016-04-20 11:40:18 +00:00
Dockerfile Fixed issue related to docker image creation 2016-04-20 11:40:18 +00:00
LICENSE Adding license and authors file 2013-12-30 13:11:49 +07:00
README.rst Restruct README file 2016-03-09 03:29:39 -05:00
requirements.txt Updated from global requirements 2016-05-17 14:05:04 +00:00
run_functional_tests.sh Removed mistral/tests/functional 2016-01-29 11:04:03 +09:00
run_tests.sh Fix postgresql unit tests running 2015-08-12 13:57:28 +03:00
setup.cfg Also package mistral_tempest_tests 2016-03-25 14:24:31 +01:00
setup.py Updated from global requirements 2015-09-17 16:39:24 +00:00
test-requirements.txt Updated from global requirements 2016-04-08 00:28:16 +00:00
tox.ini Fixing a bug in DB API method that acquires entity lock 2016-03-28 14:47:09 +07:00

Mistral

Workflow Service for OpenStack cloud.

Installation

Prerequisites

It is necessary to install some specific system libs for installing Mistral. They can be installed on most popular operating systems using their package manager (for Ubuntu - apt, for Fedora, CentOS - yum, for Mac OS - brew or macports).

The list of needed packages is shown below:

  • python-dev
  • python-setuptools
  • python-pip
  • libffi-dev
  • libxslt1-dev (or libxslt-dev)
  • libxml2-dev
  • libyaml-dev
  • libssl-dev

In case of ubuntu, just run:

apt-get install python-dev python-setuptools libffi-dev \
  libxslt1-dev libxml2-dev libyaml-dev libssl-dev

Mistral can be used without authentication at all or it can work with OpenStack.

In case of OpenStack, it works only with Keystone v3, make sure Keystone v3 is installed.

Install Mistral

First of all, clone the repo and go to the repo directory:

$ git clone https://git.openstack.org/openstack/mistral.git
$ cd mistral

Devstack installation

Information about how to install Mistral with devstack can be found here.

Virtualenv installation:

$ tox

This will install necessary virtual environments and run all the project tests. Installing virtual environments may take significant time (~10-15 mins).

Local installation:

$ pip install -e .

or:

$ python setup.py install

Configuring Mistral

Mistral configuration is needed for getting it work correctly with and without an OpenStack environment.

  1. Install and configure a database which can be MySQL or PostgreSQL (SQLite can't be used in production.). Here are the steps to connect Mistral to a MySQL database.

    • Make sure you have installed mysql-server package on your Mistral machine.

    • Install MySQL driver for python:

      $ pip install mysql-python

      or, if you work in virtualenv, run:

      $ tox -evenv -- pip install mysql-python
    • Create the database and grant privileges:

      $ mysql -u root -p

      CREATE DATABASE mistral; USE mistral GRANT ALL ON mistral.* TO 'root'@'localhost';

  2. Generate mistral.conf file:

    $ oslo-config-generator \
      --config-file tools/config/config-generator.mistral.conf \
      --output-file etc/mistral.conf
  3. Edit file etc/mistral.conf according to your setup. Pay attention to the following sections and options:

    [oslo_messaging_rabbit]
    rabbit_host = <RABBIT_HOST>
    rabbit_userid = <RABBIT_USERID>
    rabbit_password = <RABBIT_PASSWORD>
    
    [database]
    # Use the following line if *PostgreSQL* is used
    # connection = postgresql://<DB_USER>:<DB_PASSWORD>@localhost:5432/mistral
    connection = mysql://<DB_USER>:<DB_PASSWORD>@localhost:3306/mistral
  4. If you are not using OpenStack, add the following entry to the /etc/mistral.conf file and skip the following steps:

    [pecan]
    auth_enable = False
  5. Provide valid keystone auth properties:

    [keystone_authtoken]
    auth_uri = http://<Keystone-host>:5000/v3
    identity_uri = http://<Keystone-host:35357/
    auth_version = v3
    admin_user = <user>
    admin_password = <password>
    admin_tenant_name = <tenant>
  6. Register Mistral service and Mistral endpoints on Keystone:

    $ MISTRAL_URL="http://[host]:[port]/v2"
    $ openstack service create --name mistral workflowv2
    $ openstack endpoint create \
        --publicurl $MISTRAL_URL \
        --adminurl $MISTRAL_URL \
        --internalurl $MISTRAL_URL \
        mistral
  7. Update the mistral/actions/openstack/mapping.json file which contains all available OpenStack actions, according to the specific client versions of OpenStack projects in your deployment. Please find more detailed information in the tools/get_action_list.py script.

Before the First Run

After local installation you will find the commands mistral-server and mistral-db-manage available in your environment. The mistral-db-manage command can be used for migrating database schema versions. If Mistral is not installed in system then this script can be found at mistral/db/sqlalchemy/migration/cli.py, it can be executed using Python command line.

To update the database schema to the latest revision, type:

$ mistral-db-manage --config-file <path_to_config> upgrade head

For more detailed information about mistral-db-manage script please check file mistral/db/sqlalchemy/migration/alembic_migrations/README.md.

** NOTE: For users want a dry run with SQLite backend(not used in production), mistral-db-manage is not recommended for database initialization due to SQLite limitations. Please use sync_db script described below instead for database initialization.

Before starting Mistral server, run sync_db script. It prepares the DB, creates in it with all standard actions and standard workflows which Mistral provides for all mistral users.

If you are using virtualenv:

$ tools/sync_db.sh --config-file <path_to_config>

Or run sync_db directly:

$ python tools/sync_db.py --config-file <path_to_config>

Running Mistral API server

To run Mistral API server:

$ tox -evenv -- python mistral/cmd/launch.py \
    --server api --config-file <path_to_config>

Running Mistral Engines

To run Mistral Engine:

$ tox -evenv -- python mistral/cmd/launch.py \
    --server engine --config-file <path_to_config>

Running Mistral Task Executors

To run Mistral Task Executor instance:

$ tox -evenv -- python mistral/cmd/launch.py \
    --server executor --config-file <path_to_config>

Note that at least one Engine instance and one Executor instance should be running in order for workflow tasks to be processed by Mistral.

If you want to run some tasks on specific executor, the task affinity feature can be used to send these tasks directly to a specific executor. You can edit the following property in your mistral configuration file for this purpose:

[executor]
host = my_favorite_executor

After changing this option, you will need to start (restart) the executor. Use the target property of a task to specify the executor:

... Workflow YAML ...
task1:
  ...
  target: my_favorite_executor
... Workflow YAML ...

Running Multiple Mistral Servers Under the Same Process

To run more than one server (API, Engine, or Task Executor) on the same process:

$ tox -evenv -- python mistral/cmd/launch.py \
    --server api,engine --config-file <path_to_config>

The value for the --server option can be a comma-delimited list. The valid options are all (which is the default if not specified) or any combination of api, engine, and executor.

It's important to note that the fake transport for the rpc_backend defined in the configuration file should only be used if all Mistral servers are launched on the same process. Otherwise, messages do not get delivered because the fake transport is using an in-process queue.

Mistral Client

The Mistral command line tool is provided by the python-mistralclient package which is available here.

Debugging

To debug using a local engine and executor without dependencies such as RabbitMQ, make sure your etc/mistral.conf has the following settings:

[DEFAULT]
rpc_backend = fake

[pecan]
auth_enable = False

and run the following command in pdb, PyDev or PyCharm:

mistral/cmd/launch.py --server all --config-file etc/mistral.conf --use-debugger

Running examples

To run the examples find them in mistral-extra repository (https://github.com/openstack/mistral-extra) and follow the instructions on each example.

Tests

You can run some of the functional tests in non-openstack mode locally. To do this:

  1. set auth_enable = False in the mistral.conf and restart Mistral

  2. execute:

    $ ./run_functional_tests.sh

To run tests for only one version need to specify it:

$ bash run_functional_tests.sh v1

More information about automated tests for Mistral can be found on Mistral Wiki.