Commit Graph

43 Commits

Author SHA1 Message Date
Vasudeo Nimbekar 51574ef6ef Added maintenance mode
Change-Id: Ie42fcfa96044da1793f1afbff5fb2ae5534d5c2e
2023-05-31 17:31:42 +05:30
Oleg Ovcharuk 517789943a Info endpoint
For many various support reasons, Mistral should have a special
endpoint to store all necessary info data. This endpoint will read
json from created by admin info file. To configure this you should
use mistral configuration:

[api]
enable_info_endpoint = True
info_json_file_path = info.json

Change-Id: I6f344dc15a4ca5c69a6b21841544a31f95eb393f
Implements: blueprint mistral-info-endpoint
Signed-off-by: Oleg Ovcharuk <vgvoleg@gmail.com>
2022-11-17 22:06:37 +00:00
Eyal bb94ca1fed Use 406 error instead of 500 error when Service API is not supported
Closes-Bug: 1820349
Change-Id: I4cdfc1abf2634a3a922377d7ceda0585ed0c4061
2020-01-06 10:24:05 +02:00
Chen Eilat 86ae8a7e20 Change 403 exception message to something more informative and accurate
Change-Id: Ifd93f47b6635f94d05db49aa4edee369d4719fd3
2019-09-16 10:28:01 +00:00
Oleksiy Petrenko 6a672572bc Create Base class for Mistral Exceptions and Errors
Moved common logic in mistral/exceptions from
MistralError and MistralExceptions to MistralFailureBase

Change-Id: I79dc7b91c00a296a2c6d9c3b589ea3fa4fc7db48
2018-05-31 08:47:04 +00:00
Renat Akhmerov 3e04223888 Make sure not to swallow original exceptions on handling remote errors
* Also removed a custom initializer of SizeLimitExceededException with
  3 parameters in favor of creating a static method because we
  have to assume that all MistralException classes have an initializer
  with only one parameter "message" to be able to restore an exception
  on the RPC client which was raised on the RPC server.

Change-Id: Idd52bb7bb18168826644d8aaca3d96be46f8ae9e
Closes-Bug: #1750752
2018-03-13 12:36:11 +07:00
Renat Akhmerov 49e2a53a9a Remove wrapping of database exceptions in _get_collection()
* Method _get_collection() in api.py wraps all DB exceptions with
  DBQueryEntryError. It causes a problem because if it raises a
  DBDeadlock exception then it's not handled by @retry_on_deadlock
  decorator and the corresponding workflow operation gets lost.
  This patch remove this wrapping and also the exception class
  because it's not used anywhere else.

Closes-Bug: #1727152

Change-Id: If885bb63dc165aaf19001a4ff2c381732ee38982
2017-10-25 11:01:32 +07:00
Winson Chan c9fcb03c6d Allow async action execution to be paused and resumed
Allow async action execution to be paused and resumed by
updating the action execution via API. When an action
execution is paused, the state transition will cascade up
to the task execution.

Implements: blueprint mistral-action-ex-pause-resume
Change-Id: I87233d27c46cfe86a23beb8dfdc96f77e58d24c1
2017-08-02 19:02:33 +00:00
Kirill Izotov 362c2295e8 Add Jinja evaluator
Allows to use Jinja instead of or along with YAQL for expression
evaluation.

 * Improved error reporting on API endpoints. Previously, Mistral API
   tend to mute important logs related to errors during YAML parsing
   or expression evaluation. The messages were shown in the http
   response, but would not appear in logs.

 * Renamed yaql_utils to evaluation_utils and added few more tests to
   ensure evaluation functions can be safely reused between Jinja and
   YAQL evaluators.

 * Updated action_v2 example to reflect similarities between YAQL and
   Jinja syntax.

Change-Id: Ie3cf8b4a6c068948d6dc051b12a02474689cf8a8
Implements: blueprint mistral-jinga-templates
2016-10-05 11:27:29 +00:00
Dawid Deja 22244e0d62 Fix for raising excepton from kombu
Oslo wraps exceptions, we need to do same in kombu driver.

Change-Id: I85c7bc94ef991fd0afc9485ffcff0db8bc818592
Closes-bug: 1608909
2016-09-15 17:18:39 +02:00
Lingxian Kong 4e1e358c8b Add event trigger REST API
This patch adds the Mistral changes to support the new event trigger
REST API.

Change-Id: I8190ce81d46cc8296db29f41442354cdfe1a5bbd
Implements: blueprint event-notification-trigger
Co-Authored-By: Lingxian Kong <anlin.kong@gmail.com>
2016-09-13 22:39:36 +12:00
Renat Akhmerov 021caf873f Add KeyCloak OpenID Connect server-side authentication
* Changed AuthHook for Pecan that implements token validation
* Added another config option to disable SSL verification for
  KeyCloak access tokens
* Added unit tests for successful and failed KeyCloak
  authentication that use request_mock library
* Minor style changes

Change-Id: I87f8d54fc58f82952a4c68831547e6dab320230e
2016-07-08 17:31:06 +07:00
Renat Akhmerov e2c89f777d Refactoring workflow handler
* Introduced new class Workflow that manages life-cycle of running
  workflows and is responsible for managing workflow persistent state
* Moved all workflow level logic to workflow handler and Workflow class
* Changed semantics if how workflows start errors are handled.
  Previously, in case of invalid user input Mistral engine would store
  information about error in "state_info" field of workflow execution
  and bubble up an exception to the user. This approach was incorrect
  for a number of reasons including broken semantics: if an exception
  was raised due to invalid input it's normal to expect that system
  state has not changed. After this refactoring, engine only raises
  an exception in case of bad user input. That way behavior is
  consistent with the idea of exceptional situations.
* Fixed unit tests in according to the previous point
* Fixed a number of logical issues in tests. For example, in
  test_default_engine.py we expected one type of errors (e.g. env not
  found) but effectively received another one (invalid input).

Partially implements: blueprint mistral-engine-error-handling

Change-Id: I09070411fd833df8284cb80db69b8401a40eb6fe
2016-06-07 18:38:38 +07:00
Renat Akhmerov 96e6d7e403 Refactoring exception hierarchy
* Clear separation for problems that can be handled so that the program
  can continue and problems that can't handled automatically due to major
  issues in configuration, environment or code itself
* Split YAQL exceptions into two types: grammar exception and evaluation
  exception
* General NotFoundException is replaced with more specific DBEntryNotFoundException
  for better consistency with other DB exceptions and more clear semantics
* Fixed corresponding tests

Change-Id: I07f495ab316b0f164caece78b1f101219199e68c
Implements: blueprint mistral-engine-error-handling
2016-05-11 10:13:33 +00:00
Lingxian Kong f2eaea5a12 Support action_execution deletion
With this patch, users can perform operation as following:
DELETE http://127.0.0.1:8989/v2/action_executions/<action_execution_id>

NOTE:
* Added a new config item 'allow_action_execution_deletion', with default
  value 'False'.
* The 'allow_action_execution_deletion' item is set to 'True' for
  functional testing.
* Only ad-hoc action-execution can be deleted.
* Only completed action execution can be deleted.

Implements: blueprint mistral-action-execution-deletion
Closes-Bug: #1488157
Change-Id: I3729636911a42c273c5a7b2d7fbdaae0da398e31
2015-09-07 13:18:41 +00:00
LingxianKong dba860a15d Add pagination support for workflows query API
Add query params for workflow list REST API:

* limit: return a maximun number of items at a time, default is None, the
  query result will include all the resource items, which is backward
  compatible.

* marker: the ID of the last item in the previous list.

* sort_keys: columns to sort results by. Default: created_at.

* sort_dirs: directions to sort corresponding to sort_keys, "asc" or
  "desc" can be choosed. Default: asc. The length of sort_dirs can
  be equal or less than that of sort_keys.

Change-Id: Ie73d4457193999555ce9886d4de1297b4d0bc51d
Partially-Implements: blueprint mistral-query-enhancement
2015-08-19 17:01:56 +08:00
LingxianKong 4960da9496 Add coordination util for service management
Tooz is a Python library that provides a coordination API. Its primary
goal is to handle groups and membership of these groups in distributed
systems.

This patch adds coordination util to Mistral, which makes use of Tooz
libary.

Change-Id: Icbf3086d01649af813727f0972d6d5b0631d6afb
Partially-Implements: blueprint mistral-service-api
2015-07-28 15:59:41 +08:00
Moshe Elisha 30589cfa5f Support large datasets for execution objects
Allow the cloud provider to configure the
size limit of workflow input, action input,
action output, task publish and workflow params

This will allow users to execute workflows that
handle much bigger datasets from the ones which
are supported today.

The changes made in order to achieve that goal:
* Increase DB columns size so they will no longer
  be the barrier
* Add configuration options to control the limit
* Add event listener on the columns to enforce
  the size limitation

Change-Id: If7c29f9325e60ce456e23d5c7b6ceb3477a028d4
Implements: blueprint support-large-datasets
2015-07-27 12:29:07 +00:00
LingxianKong 23cddf7159 Consider input default values in ad-hoc action
If the ad-hoc action input default value is defined in the spec, the input
param does not needed to be provided for action execution.

* rename validate_workflow_input function to validate_input for common
purpose of both workflow/action input validation.
* delete WorkflowInputException definition, use InputException instead.
* add unit test for ad-hoc action execution.

Partially Implements: blueprint mistral-default-input-values

Change-Id: I3e25c1ce9f7f93dfce3b5981221cf752603ec49e
2015-04-22 10:08:45 +08:00
Nikolay Mahotkin 7fd5a7a0c1 Moving to YAQL 1.0
* Fixed ProxyAwareDict according to YAQL
   convert data when evaluating expression
 * Fixed expression tests
 * Fixed Engine tests where we refer to unexisting
   variable in context
   (now YAQL raises an error when it doesn't find a
    value using given key)
 * Fixed tests on join (new way to check test correction)

 * YAQL 1.0 has its own builtin functions len() and str
   therefore our ones were deleted.
 * YAQL 1.0 uses '$.where' function instead of '$[$...]'

Implements: blueprint yaql-v1-0

Change-Id: I1b46c4e12aee6f25d1e9ca9daa1da059baf6fb68
2015-04-09 15:57:44 +03:00
Winson Chan 82fb7ee5f6 Harden v2 DSL schema for validation
Currently, syntax errors in the DSL do not surface until runtime while
in the middle of running a workflow. The change here hardens the v2
model and schema to catch obvious errors in the DSL prior to the
definition being created and updated. This is also the pre-requisite
for the API endpoint to validate workflow/workbook DSL.

Change-Id: I0efbfcc3a42446951fd3550892768a668c6283d1
Implements: blueprint api-validate-dsl
2015-03-27 05:31:04 +00:00
Nikolay Mahotkin 3202940f1a Add validation on 'with-items' input
Partially implements blueprint mistral-with-items

Change-Id: I5c2446133ab6447ffd8f9c6336b11cc8fb340804
2015-01-16 13:00:27 +03:00
Renat Akhmerov 7eb6a0f66d Adding workflow parameters validation
Change-Id: I55b4a03296ddbd1468c2a7dd1cc7b7e2d867351d
2014-09-18 18:41:26 -07:00
Kirill Izotov f25d099bcb Implement REST API v2.0
Change-Id: I6c46f3b691b0e721ca47b29f7a749338397d6dc6
Implements: blueprint mistral-rest-api-2.0
2014-09-01 11:17:53 +07:00
Renat Akhmerov 3b8e451d87 Refactoring DB access layer
* Breaking DB api and DB models into separate versions
* Fixing unit tests and dependent code
* Preparing DB models for the new API/engine

TODO:
* Adjust v2 DB models according to the new spec

Change-Id: I763cc3f401b8040a182733750ce05577653e1d35
2014-08-13 11:14:29 +07:00
Renat Akhmerov f997ca183d Implementing DSL specification v2 (partially)
* Rewriting package 'workbook' to have v1 and v2 separately
* Refactoring all required places to use v1 spec explicitly
* Refactoring and making specs more consistent

TODO:
* Fully implement spec v2 when it's complete

Change-Id: I4d6949588635ff45775f68186ea43b16163b6a72
2014-08-13 11:14:29 +07:00
Renat Akhmerov 8f7a1a221a Initial commit for the new engine
* Skeleton for the new engine
* Main modules and interfaces (Engine, WorkflowHandler, policies)
* Sketches of main engine methods
* Reverse workflow handler
* Function to check valid state transitions
* Unit tests

Change-Id: Id6ae293154bca7cab69965725ea6960d5f8d8790
2014-08-06 16:24:26 +07:00
Winson Chan 59830a49f1 Sync code with oslo-incubator
Updated openstack-common.conf and remove outdated modules. Ran update script
in oslo-incubator to generate modules in the mistral/openstack and tools
directories. Sqlalchemy backend has changed significantly in oslo-incubator.
Refactored mistral db api to address these changes and updated the base test
class DbTestCase accordingly.

Change-Id: I61327c33c0c8bc616af5e7633634461a2d7ac691
Implements: blueprint mistral-sync-with-incubator
2014-05-29 15:07:15 -07:00
Angus Salkeld 1ceb4b1e8a Add/Fix all error handling mechanism on REST API
* Refactor error handling
 * add tests for correct error codes

Closes bug: #1320136
Co-Authored-By: Angus Salkeld <angus.salkeld@rackspace.com>
Change-Id: Ia33e19cab4879164acb7c8268c9c657f4196df45
2014-05-28 12:39:03 +10:00
Angus Salkeld 5e9ffd5c47 Cleanup exceptions and add http code
- Remove redundant constructors
- always use "code" as an http_status
- fix the default message strings so you can pass nothing into the
  exception constructor and it will work.
- add some basic tests

Partial-bug: #1320136
Co-Authored-By: Nikolay Mahotkin <nmakhotkin@mirantis.com>

Change-Id: I9e21c6d5d39f1203324a37a39e5fd6069062b733
2014-05-27 09:31:53 +00:00
Nikolay Mahotkin a8ae8e336e Fix 500 status code on DELETE request
Closes bug: #1318620

Change-Id: I0a5876111dfbe8f1284f28b3b9bf914779c1f560
2014-05-12 16:11:32 +04:00
Renat Akhmerov 32720f2c72 BP mistral-actions-design (add new actions package)
* Base class for actions (Action)
* Class for representing action namespaces (NameSpace)
* Module action_factory.py for registering action classes, accessing
  them and creating action instances
* Unit tests for action_factory.py
* Standard actions (echo, http, email)

TODO:
* Ad-hoc per-workflow namespaces and actions
* Mistral HTTP standard action
* Refactoring executor to use new action infrastructure
* Remove old action infrastructure
* Action plugin architecture

Partially implements: blueprint mistral-actions-design
Partially implements: blueprint mistral-change-rest-api-to-http

Change-Id: I8e79b1f8173809584f0156e666e1675f5bd7bb37
2014-04-14 19:24:27 +07:00
Nikolay Mahotkin 0884cd0ff0 Implement new object-model specification
* Implemented new object model
 * Implemented spec validation
 * Old DSL parser was deleted
 * All code is replaced by new workbook spec
 * Also tests are fixed
 * events -> triggers
 * Unit tests

Implements: blueprint mistral-dsl-model
Partially implements: blueprint mistral-dsl-validation
Partially implements: blueprint mistral-rename-event-to-trigger

Change-Id: I782b7983ddc724375229587f467c55ad9341478b
2014-03-12 14:58:54 +04:00
Renat Akhmerov 31ed10aa18 Working on Data Flow (step 3)
* Refactored tests hierarcy (moved get_resource to the base class)
* Fixed logic in abstract engine (transaction scoope was wrong)
* Added stub methods for context manipulations (not everywhere yet)
* Refactored actions
* Created ECHO action to be able to emulate required output
* Added simple data flow test (two dependent tasks)

TODO:
* More tests
* Refactor actions according to the latest discussions

Change-Id: I5ba5e330110889014eeca53501ddae54dc9a1236
2014-03-07 16:53:02 +07:00
Jenkins f1847fe5c1 Merge "Partially fixed the pylint errors" 2014-03-04 12:01:59 +00:00
Timur Nurlygayanov ba90868050 Partially fixed the pylint errors
Fixed several errors:
   E1003
   E1101

It is impossible to fix all E1101 errors: looks like we have
problems with outdated DataBase models.

Change-Id: I46863c553f033e5f9e4ae9cb9c20e297c099a114
Partial-Fixes: bug #1281164
2014-03-03 13:26:05 +04:00
Timur Nurlygayanov e1cfad9f0b Fixed critical pylint warnings
Fixed the following pylint warnings:
   W0231
   W0621
   W0621

Change-Id: I6d49a19f843ab2b63740199ef387e7e878fa030f
Partial-Fixes: bug #1281164
2014-02-25 23:25:42 +04:00
dzimine 1c15945f86 Add negative tests to api
1. Add couple of negative tests, find the way, more to go.

2. Add assertNotFound to the base test class for convenience.

3. MistralException - added default message to enable default instantiation - make mock.assertRaise fails when exception has no default constructor

Change-Id: I708637e3995597a819571a90f3292d6e34deab4e
2014-01-29 19:01:27 -08:00
Renat Akhmerov 44e38c97b7 Fixing and refactoring authentication
* Moved pecan configuration to oslo config
* Refactored functional base test
* Got rig of thread local related code in mistral/context.py
* Added new exception ApplicationContextNotFoundException
* Fixed example configuration file
* Made minor cosmetic changes (blank lines, naming)

Change-Id: I1899ce2562a34ebafa20c5735bdf4f0c80dd0175
2014-01-27 12:11:28 -05:00
Nikolay Mahotkin 0934507ed2 Step 1 refactoring Mistral engines
* Action definition was combined in actions module
 * workflow from both single and scalable engines were deleted
 * task from single engine was deleted
 * unit test 'test_workflow' was deleted due to deleting workflow
 * minor fixes to single engine

 Next step will be extracting and combining common parts
 of scalable and single engine.

Change-Id: I15fbbb7f9d5e453c17625423eeb1bf841a19db18
2014-01-14 15:57:28 +04:00
Nikolay Mahotkin 2176d57d15 Fix workbook POST duplicate exception
* 400 status code response on duplicate error
 * new exceptions - Mistral, DBDuplicateEntry
 * import exception from openstack-common

Fixes bug: #1263942

Change-Id: Ia802db5c6b30be96cb0b8ce2cfc0f7fd04122302
2013-12-26 16:20:15 +04:00
Renat Akhmerov 50bebda734 Various fixes related to end-to-end testing
* Fixed several problems in scalable engine
* Fixed engine interface
* Fixed several problems in REST API
* Changed task DB model
* Fixed DSL parser
* Added scripts for end-to-end testing

Change-Id: Icbcc46d11a6c687d0ae3aad339ca5f5134c50195
2013-12-19 16:10:03 +07:00
Renat Akhmerov 3fa58bfb8f Add explicit DB transaction management
* Added methods on DB API for explicit transaction demarcation
* Added @session_aware() decorator maker
* Refactoring SqlAlchemy implementation of DB API
* Added all tests for DB API
* Added methods to access thread local variables in mistral/utils.py
* Fixed API Resource class to ignore unset values in transformations

Change-Id: I5fae196f89c77a5e355207907bd08983969922c3
2013-12-17 19:54:39 +07:00