Commit Graph

395 Commits

Author SHA1 Message Date
Vadim Zelenevsky cadfe9dca2 Fix maintence mode
Added MaintenceHook to app configuration
Refactored maintence service
Fixed sql queries
Fix maintence controller

Closes-Bug: #2058009
Signed-off-by: Vadim Zelenevsky <wortellen@gmail.com>
Change-Id: Ica41e8208b29aeba6e781801540843d46375c3d1
2024-04-08 07:24:41 +00:00
Zuul 973e6ac996 Merge "Add optional healthcheck middleware" 2023-12-14 00:35:55 +00:00
Vadim Zelenevskii ac8b2d0488 Add checksum field to wf definition
We have no way to determine whether the workflow definition has
changed or not.
This complicates the work with Mistral for external services.
A 'checksum' field has been added to workflow_definitions_v2
to solve this issue.

Implements: blueprint mistral-add-checksum-field-to-wf-definition

Change-Id: I99d095c6c74c62f134aedfa3a63308a0712db38d
2023-11-29 07:55:28 +00:00
Vasudeo Nimbekar 51574ef6ef Added maintenance mode
Change-Id: Ie42fcfa96044da1793f1afbff5fb2ae5534d5c2e
2023-05-31 17:31:42 +05:30
Zuul 431ece5581 Merge "Info endpoint" 2023-05-17 09:05:03 +00:00
Zuul 4289317a91 Merge "Task skipping feature" 2023-02-14 13:22:17 +00:00
Zuul 5e581ee040 Merge "Adding root_execution_id parameter to mistral loggers" 2023-02-14 10:44:01 +00:00
Vasudeo Nimbekar 88e7e7ceee Adding root_execution_id parameter to mistral loggers
After this patch, user can update logging format to include root_execution_id in logs, which will be helpful to find and debug logs related to specific workflow execution.

  - Logs about creation and status changes of Mistral entities(execution,
    task, action execution, etc) are changed to INFO log level.
  - User can update logging_context_format_string to include root_execution_id in logs.

Implements: Implements: blueprint improve-mistral-loggers

Change-Id: I54fe058e5451abba6ea7f69d03d498d78a90993e
2023-02-13 05:01:39 +00:00
Zuul c9bd45d073 Merge "Add "fields" filter support on single objects" 2023-02-09 13:06:08 +00:00
Takashi Kajinami f17dd7a04b Add optional healthcheck middleware
This change introduces a new option, [healthcheck] enabled, which
enables the healthcheck middleware in mistral-api pipeline.

This middleware allows status check at /healthcheck path, which is
useful for load balancers or any monitoring services to validate health
of its backend services.

This change is created based on the same change proposed to ironic[1].

[1] 6f439414bdcef9fc02f844f475ec798d48d42558

Co-Authored-By: Jim Rollenhagen <jim@jimrollenhagen.com>
Change-Id: I9bf3de8a5ae6a8c9346285147732b773a3667f7e
2023-02-03 04:09:13 +00:00
Tobias Urdin b6a47992e7 Fix sorting error when type is different
There was a logical flaw where we compared types
that were different causing a TypeError.

There was also a flaw in that we default to the
name of the action when sorting if the key does
not exist, to compare the data both value should
come from the same key as well otherwise they
should be treated as not equal since the data
cannot be.

Change-Id: Idcb276912582bb097dc5c1c9692facde63d5886b
2023-01-18 21:20:28 +01:00
Xavier Hardy 9c5324ce9a Add "fields" filter support on single objects
Change-Id: Iba0401445921f9ea7932628c05590472307ba83a
Closes-Bug: #1718214
Signed-off-by: Xavier Hardy <xavier.hardy@corp.ovh.com>
Co-Authored-By: Oleg Ovcharuk <vgvoleg@gmail.com>
Signed-off-by: Oleg Ovcharuk <vgvoleg@gmail.com>
2022-12-21 06:40:50 +00:00
Vasudeo Nimbekar 87c08ff421 Update get execution's tasks functionality
After this patch, it will validate execution-id exists in the DB while fetching tasks for the execution-id So, GET /v2/executions/execution_id/tasks API will return 404 for absent execution id.

Closes-Bug: #1998210
Change-Id: I6ac05f4b87c470a68cd67f19d1bd95a4d6cebe59
2022-12-01 07:39:48 +00:00
Oleg Ovcharuk e72a4e9a70 Task skipping feature
This patch adds an ability to rerun failed workflow by
skipping failed tasks. Workflow behavior in skip case could
be configured by new fields in task definition:
* on-skip
* publish-on-skip

Change-Id: Ib802a1b54e69c29b4d0361f048c2b9c076a4c176
Implements: blueprint mistral-task-skipping-feature
Signed-off-by: Oleg Ovcharuk <vgvoleg@gmail.com>
2022-12-01 01:47:30 +03:00
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
Zuul 95e30947d7 Merge "Do not guess content from extension on API" 2022-09-09 13:10:05 +00:00
Arnaud Morin 2a312cc814 Do not guess content from extension on API
When getting a cron trigger (but also any other object) by name, pecan
core will try to guess the content_type from the extension.
While for most name, the guess will fail, it may succeed, e.g. when a
name is ending with '.pl'.
Pecan guess it as a perl file and then reject the call (with a 404
error).

The fix is to tell pecan to not guess any content_type from extension by
setting guess_content_type_from_ext to False on initialisation.

Closes-Bug: 1987418

Signed-off-by: Arnaud Morin <arnaud.morin@ovhcloud.com>
Change-Id: I1bc20b953787cae9b42d12bb5eb3c7a94ed4bbdd
2022-09-09 10:40:22 +02:00
Tobias Urdin 1a6f5d0e5f Added sorting and marker for pagination of actions
This solves the sorting and marker for pagination
when listing actions.

Change-Id: I9bb15642585af22ad354dd4f8f2253a47129639e
2022-08-15 08:07:13 +00:00
Renat Akhmerov 421f84334b Fix a field name in the CodeSource class sample
Change-Id: Ia64c4e7fc7bc8e41d6b2e14d6372417e9c60b442
2021-01-15 06:43:04 +00:00
Ghanshyam Mann 7cf2014c2e [goal] Deprecate the JSON formatted policy file
As per the community goal of migrating the policy file
the format from JSON to YAML[1], we need to do two things:

1. Change the default value of '[oslo_policy] policy_file''
config option from 'policy.json' to 'policy.yaml' with
upgrade checks.

2. Deprecate the JSON formatted policy file on the project side
via warning in doc and releasenotes.

Also replace policy.json to policy.yaml ref from doc and tests.

[1]https://governance.openstack.org/tc/goals/selected/wallaby/migrate-policy-format-from-json-to-yaml.html

Change-Id: I3b9aeb3379a76f7e40dab0c46e27f4447a0c3d03
2020-12-22 16:47:46 +07:00
Renat Akhmerov a73fe5b8a3 Fix dynamic actions further
* Reworked /code_sources and /dynamic_actions API endpoints to
  simplify them. For now they don't work with multiple objects and
  they are consistent with other endpoints. If needed, we'll add
  support for multiple objects (i.e. adding multiple dynamic actions
  with a single request) later in a backwards compatible manner.
* Simplified unit tests.
* Got rid of services/*.py modules since they didn't do anything
  useful. They were just wrappers around DB API calls.

Change-Id: Ib5a53f1f1a185f0395ffae1ab0c401633fcdd0fc
2020-12-03 16:51:25 +07:00
Renat Akhmerov f78f33507e Code improvements after the dynamic actions patch
* Style improvements to make sure the code is compliant with the
  coding guidelines
* Fixing small but important things like the mismatch between the
  sinatures of the methods find_all() in the DynamicActionProvider
  class and the base ActionProvider interface.
* Improved the tests.
* Simplified the implementation of DynamicActionProvider.

Change-Id: Idbfb15b4c3bb415e7fa9c7ece27eabfe674b6059
2020-11-23 15:33:54 +07:00
ali 9be4f8e119 created a new Api endpoints and added dynamic actions
* added dynamic actions:
     these actions are created and modified in runtime,
     each action needs a code source to be imported from and a
     class name.

 - there are 2 new endpoints:
    - /v2/code_sources/:
       used to add new code sources to mistral.
    - /v2/dynamic_actions/:
      used to add dynamic actions to mistral in runtime

 - a new Action provider (DynamicActionProvider) was added:
    it provides the actions created from the dynamic actions api.

Change-Id: I9fe8c28ffdef71016d9dc13aea60a288c8ebaa0a
Signed-off-by: ali <ali.abdelal@nokia.com>
2020-11-18 10:15:26 +00:00
Renat Akhmerov 06a0f33476 Refactor Mistral with Action Providers
* This patch refactors Mistral with the action provider concept
  that is responsible for delivering actions to the system. So
  it takes all the burden of managing action definitions w/o
  having to spread that across multiple subsystems like Engine
  and API and w/o having to assume that action definitions are
  always stored in DB.
* Added LegacyActionProvider  that represents the old way of
  delivering action definitions to the system. It pretty much just
  analyses what entries are configured in the entry point
  "mistral.actions" in setup.cfg and build a collection of
  corresponding Python action classes in memory accessible by names.
* The module mistral/services/actions.py is now renamed to
  adhoc_actions.py because it's effectively responsible only for
  ad-hoc actions (those defined in YAML).
* Added the new entry point in setup.cfg "mistral.action.providers"
  to register action provider classes
* Added the module mistral/services/actions.py that will be a facade
  for action providers. Engine and other subsystems will need to
  work with it.
* Other small code changes.

Depends-On: I13033253d5098655a001135c8702d1b1d13e76d4
Depends-On: Ic9108c9293731b3576081c75f2786e1156ba0ccd
Change-Id: I8e826657acb12bbd705668180f7a3305e1e597e2
2020-09-24 11:10:33 +00:00
Q.hongtao 4bc6162515 Remove six library
Remove six-library Replace the following items with Python 3 style code.
- six.interger_types
- six.itervalues
- six.text_type
- six.string_types
- six.StringIO
- six.next
- six.b
- six.PY3

Change-Id: I299c90d5cbeb41be0132691265b8dcbeae65520e
2020-09-23 10:27:12 +08:00
ali c36cbe0a11 added statistics-only in report Api and a new field in statistics
*added a new parameter to the execution report Api,
 statistics-only: the Api will only return the statistics without
 the execution data.

*added a new field to statistics,
 estimated_time: the estimated remaining time in seconds for the
  execution,it is the average run time of the last 20 successful
   executions of the same workflow
   - if no previous successful executions are found -1 is returned
   - if the runtime of the current execution is higher than the
    average then 1 is returned
    
Change-Id: I7038d6d2a48f9f0455545f6be8dce33a48b25e1c
Partially-Implements: blueprint mistral-executions-report-return-statistics-only
Signed-off-by: ali <ali.abdelal@nokia.com>
2020-05-04 06:50:47 +00:00
Zuul 680a9e2e07 Merge "wrapped the value of parameters in inputs(in wf get API) with ""." 2020-01-28 09:59:24 +00:00
ali 06e776e6e3 Added a new API to fetch sub-execution of an execution or a task
*the new endpoints are:

   v2/executions/{ex_id}/executions
   v2/tasks/{task_id}/executions

  it returns a list of execution resources, by default the API will
  return all sub-executions

  the API can take 3 parameters:

  errors_only: returns only the error routes
               - default is False
  include_output: includes the output field for the returned executions
                  - default is False
  max_depth: the max depth for the returned executions
             - if a negative value is given, then the API will return
               all sub-executions
             - default is -1

 Partially-Implements: blueprint mistral-execution-origin

Change-Id: I2a4c5e6890dbb4de868ce885d51341b15e359233
Signed-off-by: ali <ali.abdelal@nokia.com>
2020-01-23 08:50:28 +00:00
ali 4a6309683b wrapped the value of parameters in inputs(in wf get API) with "".
the input field of workflow-get API is ambiguous, and not well defined,
 2 different inputs can have the same value for the input field.

 for example :

   input:
     - first
     - second: "value, third"

  and:

    input:
     - first
     - second: "value"
     - third

 for both it was: input ="first, second=value, third"

 now it is:
 for the first: input ="first, second=\"value, third\""
 and for the second: input ="first, second=\"value\", third"

 Closes-Bug: 1631541

Change-Id: I4b3fc7e0ad4552022d44c3bdd8c87004f5e8ff46
Signed-off-by: ali <ali.abdelal@nokia.com>
2020-01-19 14:20:51 +00:00
ali 504243bcef Add 'interface' field to Workflow resource
* Workflow resource(returned by workflow-get APIs) has a new JSON field
 called 'interface', it contains the inputs and the outputs.

  -Both input and output are lists.
  -The output list contains the output param names.
  -The input list contains the inputs, if the input has a default value,
   the entry in the list will be a JSON object, with the name of the
   input and the default value, otherwise its the input param name.

   For example:
     {"input": [ "input_with_no_default_value",
   { "string_input": "some_string" },
   {"json_input": {
     "defaultKey": "defaultValue"
    }}],
     "output":["output1","output2"]}

Change-Id: Id9be6c1d9bbe4a4c965530364833e71f8b7cacc6
Implements: blueprint mistral-workflow-outputs-in-wf-apis
Signed-off-by: ali <ali.abdelal@nokia.com>
2020-01-16 14:13:34 +00:00
Zuul e986812dc9 Merge "Don't use eventlet.monkey_patch under wsgi" 2020-01-09 12:54:51 +00:00
Zuul 19792f1f70 Merge "Add namespaces to Ad-Hoc actions" 2020-01-09 10:20:10 +00:00
ali 20c3408692 Add namespaces to Ad-Hoc actions
added namespace for the actions, actions can have the same name if they
 are not in the same namespace, when executing an action, if an action
 with that name is not found in the workflow namespace or given
 namespace mistral will look for that action in the default namespace.

  * action base can only be in the same namespace,or in the
    default namespace.
  * Namespaces are not part of the mistral DSL.
  * The default namespace is an empty string ''.
  * all actions will be in a namespace, if not specified, they will be
    under default namespace

Depends-On: I61acaed1658d291798e10229e81136259fcdb627
Change-Id: I07862e30adf28404ec70a473571a9213e53d8a08
Partially-Implements: blueprint create-and-run-workflows-within-a-namespace
Signed-off-by: ali <ali.abdelal@nokia.com>
2020-01-07 08:10:53 +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
Eyal 1981e63b3f Don't use eventlet.monkey_patch under wsgi
This causes errors and is not recommended.
It also solves the problem of coordination not
working properly under wsgi

Change-Id: Ie3052d8cdc047f8a46e139f533a63f8c36d2906d
Closes-Bug: 18008953
2019-12-31 15:14:10 +02:00
Eyal d838607b2f Add coordination support for devstack
This way we can test the service api later on gate

In order to use etcd in gate few changes were made:
* All identifiers must be byte type (group type, member id)
* Tooz has a built-in mechanizm for heartbeat no need to implement it
* Need to use eventlet monkey patch since etcd client uses blocking
  methods
* Services name must be identical to LAUNCH_OPTIONS used in cli
* Gate coordination url should be define with a schema of etcd+http
  which is the etcd gateway and works better then just etcd

Change-Id: I772651e33eada4a5c2149bfa867095c277eddeed
2019-12-25 10:38:29 +02:00
ali 6948e50de8 Allow the prefixes like "eq:" and "neq:" in the custom REST UUID type
* Fields of type UUID with a filter prefix are denied because they
  don't match the UUID string format. E.g.
  "eq:6c07a453-c5e1-4bbe-97ed-3cb77b4f55ff" will throw an
  InputException. This patch makes the change that allows to have:
  "eq:" "neq:" "gt:" "gte:" "lt:" "lte:" "has:" "in:" "nin:" prefixes
  in a value of such fields.

Closes-Bug: #1792875
Change-Id: I26667a82ec768c858f0282124864e377d8cf39f4
Signed-off-by: ali <ali.abdelal@nokia.com>
2019-12-18 12:05:57 +00:00
Oleg Ovcharuk e596ee2e63 Enlarge tags support
Workflow and task executions will inherit tags from
definition. Executions filtering by tag is included.

Change-Id: Id5d615b829901258af2be7ca99178ad92b60d1fb
Closes-Bug: #1853457
Signed-off-by: Oleg Ovcharuk <vgvoleg@gmail.com>
2019-11-29 18:40:37 +03:00
Renat Akhmerov c49212e171 Make it possible to set None to REST API filters
* Added a list argument to the method get_all() of the executions
  API controller class that may contain names of columns that a
  client wants to set to the null value (None internally in the
  code) in the query string. Thereby we're getting the ability to
  filter API entities (currently only workflow executions) fetched
  with the get_all() by some fields that are assigned to the None
  (null from the API perspective) value, i.e. typically it means
  that a value of a field is not defined.

Closes-Bug: #1702421
Change-Id: I78fbf993519beb63ee9aef7058bdcb40f0a12ec3
2019-11-18 12:15:34 +07:00
Eyal ab4d4a5807 Fix the global publish for task
If there is a root execution then lazy load the
params field of the root execution

Change-Id: I6b188e315007391c738b8f821fad91c4fd8572ae
2019-10-10 17:15:39 +03:00
Renat Akhmerov 7a6aac0f5f Fix "root_execution" lazy loading issue and refactor execution.py
* There's an issue with lazyly loaded field of WorkflowExecution
  model occuring on GET /v2/execution/<id> because the logic
  that calculates "published_global" of the execution rest resource
  hits "root_execution" field out of transaction scope indirectly
  within the "data_flow.get_workflow_environment_dict" method.
  This patch makes refactoring of this logic and calculates
  globally published variables of the workflow execution simply
  as its context that doesn't contain all internal data like
  "__execution" and "openstack".
* Other style change.

Closes-Bug: #1846152
Change-Id: Ic8609e55930e2ed13653e79e8ca7a31c951d9030
2019-10-02 11:02:52 +00:00
Renat Akhmerov ac41f94d11 Add an ability to disable workflow text validation
* For the sake of the service performance, it may make sense to
  disable validation of the workflow language syntax if it is
  affordable for a particular use case. For example, if all
  workflows are auto-generated by a 3rd party system and tested
  thoroughly (either by running them with Mistral or at least
  validating them via the special Mistral endpoint) then we can
  safely disable validation of the language syntax when uploading
  workflow definitions. For production systems it makes a big
  difference if workflow texts are large (thousands of tasks).
  This patch adds the boolean parameter "skip_validation" for API
  requests like "POST /v2/workflows" to disable validation, if
  needed, and the new configuration property "validation_mode"
  to set a desired validation mode.
  The option is an enumeration and has the following valid values:
    1) "enabled" - enabled for all API requests unless it's
       explicitly disabled in the request itself
    2) "mandatory" - enabled for all API requests regardless
       of the flag in the request
    3) "disabled" - disabled for all API requrests regardless
       of the flag in the request
  "mandatory" is choosen as the default value for this new
  property to keep compatibility with the previous versions.
* Minor style changes.

Closes-Bug: #1844242

Change-Id: Ib509653d38254954f8449be3031457e5f636ccf2
2019-09-27 04:33:04 +00:00
Renat Akhmerov 64c4038b2c Optimize creation of language specs
* Various simple optimizations for creation of specs. Mostly
  additional caching of non-growing data related to the
  structure of the language spec classes. For huge workflows
  with thousands of tasks these changes reduce execution time
  by dozens of seconds.
* Minor style changes.

Partial-bug: #1844242
Change-Id: Ia700e25752d9d35ece18609f2977e6568062e4bf
2019-09-19 05:03:13 +00:00
ali 7e7f1cb92b moved generic util functions from mistral to mistral-lib
Depends-On: I780c270e4b1a184d7d4dcc580d23697ba75edab1
Closes-bug: #1815183
Change-Id: I5a1d402baa3f69c37f9347c8b3d02a83b8f60423
2019-09-13 04:06:27 +00:00
Eyal 9804e74d52 Add "published_global" field to the task execution REST resource
Closes-bug: #1751007
Change-Id: I3129846598784aec43d7f97cead1e98251ac774b
2019-09-05 04:37:03 +00:00
Renat Akhmerov 6c0bd2a268 Add "retry_count" field into workflow execution report
Change-Id: I1c937ff05c4a1f3e28010427c03e3e4f113f6fba
Closes-Bug: #1814850
2019-08-16 17:05:43 +07:00
Renat Akhmerov dfc3277ffd Initialize the lazily loaded execution "input" field in API
* After the recent change that made all potentially heavy fields
  of execution objects lazily loaded, some clients using Mistral
  APIs started crashing because they expect to get "input" field
  in JSON of execution objects that Mistral API returns. It wasn't
  present though because we did not initialize it explicitly in
  the API controller.
* Unfortunately, there's no easy way now to cover this change in
  the API tests just for how they are organized: they mock all
  DB calls and return all fields already initialized. We may want
  to refactor these tests moving forward.

Change-Id: I683c79fa0a3ab23a16c493ce2314a506dfee9749
2019-06-24 13:18:50 +03:00
Renat Akhmerov 0c3b630609 Make more JSON fields in execution objects lazy-loaded
* Some fields of execution objects can be large and, what's even more
  important, their size is defined by user input. Making these fields
  lazy-loaded reduced the amount of data loaded from DB in those
  methods where ther are not needed. For example, "spec" field of the
  WorkflowExecution class is rarely needed because the corresponding
  specification Python object gets cached. It's proven to reduce
  the execution time in some cases by ~5-10%.
* Fixed failing test

Change-Id: Ica0ba2ffa312891483745d276d04c95985c7f4c2
2019-06-17 15:22:31 +07:00
Eyal 97b493ade6 Don't use default mutable parameter
Using default mutable parameter is bad.
Default parameters are evaluated only once
if you mutate it you will get unexpected results.
Since we don't mutate here the default paramter, make
sure it is unmutable.

Change-Id: Ib5c451a8c8cad7b6c9a009369c1c039563023368
2019-04-15 10:30:34 +03:00
Vlad Gusev ca1acb656c Add http_proxy_to_wsgi middleware
This sets up the HTTPProxyToWSGI middleware in front of Mistral API. The
purpose of this middleware is to set up the request URL correctly in
the case there is a proxy (for instance, a loadbalancer such as HAProxy)
in front of the Mistral API.

The HTTPProxyToWSGI is off by default and needs to be enabled via a
configuration value.

It can be enabled with the option in mistral.conf:
[oslo_middleware]
enable_proxy_headers_parsing=True

Closes-Bug: #1590608
Closes-Bug: #1816364
Change-Id: I04ba85488b27cb05c3b81ad8c973c3cc3fe56d36
2019-03-09 01:51:59 +03:00