Commit Graph

28 Commits

Author SHA1 Message Date
Vadim Zelenevsky 737e09646f Headers propagation from an execution request to actions/notifications
Currently Mistal doesn`t support distribution tracing, which means
that there`s no way to propagate traceId/spanId from an execution to
related actions/notifications.
It leads us to an issue, because according to distribution tracing
principles "traceId" should remain the same during the discovery
process, which includes Mistral worflow execution.
Proposed solution is to keep some headers from execution request
and propagate them later to actions/notifications.
Regexp can be stored as env variable to define headers which
will be propagated.

Implements blueprint add-headers-propagation

Change-Id: Id8cc900a7d94286e79f1ece4dc4177383263f55c
2024-03-14 17:12:17 +03:00
Oleg Ovcharuk 5d7fd30ba3 New fields added to action execution context
* with_items_index describes the current index of action,
if there is no with-items tasks it should be 0.
* task_rerun_no describes the current rerun index,
if it is first run it should be 0.
* task_rerun_id specifies id task has within
each rerun. This id should be refreshed after each rerun.

All these fields will be helpful for writing custom actions

Change-Id: I2b76f5cedcac942e3b6a6e9488ae89024c4f1b34
Signed-off-by: Oleg Ovcharuk <vgvoleg@gmail.com>
2024-03-14 11:32:21 +00:00
Andras Kovi 245c1272f2 Add more specific description to param_spec
Change-Id: I312f1f4b26de31b7a0b6040e371e2e02760728d9
2020-09-04 07:38:03 +02:00
Renat Akhmerov f818f1f02c Add main entities related to action providers
* This patch adds the base infrastructure for the new concept
  that we call Action Providers. It will allow to refactor
  Mistral in a way that all action management will be encapsulated
  with action providers. For example, Mistral Engine needs to
  schedule actions while processing a workflow. Now it has to
  access DB itself to find an action definition (meta info about
  what this action is, like python class, input params etc.),
  then prepare input parameters, validate parameters and send a
  message to an executor to run it. In many other places, Mistral
  also directly access DB to fetch an action definition. It's
  not flexible because we assume that definitions of Mistral
  actions must always be stored in DB. The concept of an Action
  Provider allows moving away from that limitation. A particular
  implementation of the ActionProvider interface can store action
  definitions in any suitable way, even fetching them using
  various transport protocols like AMQP, HTTP, TCP, or anything
  else. An action provider may also generate action definitions
  dynamically, like creating wrappers around a set of operating
  system commands. But for the rest of the system it won't matter
  what happens inside action providers. All details will be
  hidden behind a unified interface.
* Added ActionDescriptor interface and its convenience base
  abstract implementation. ActionDescriptor is an entity
  representing an action before it's instantiated. It carries
  the most important meta information about an action like name,
  description, input parameters etc. It is also responsible for
  validating action input parameters and instantiating a real
  action.
* Added PythonActionDescriptor which represents a regular action
  written as a Python class.
* Added CompositeActionProvider that delegates calls find() and
  find_all() to a collection of other action providers.
* Minor style changes.

Partially implements: bp/mistral-action-providers

Change-Id: Ic9108c9293731b3576081c75f2786e1156ba0ccd
2020-09-03 17:16:50 +07:00
Renat Akhmerov d888fe240c Remove misplaced constants describing worklow task types
* These constants have nothing to do with this project. They should
  be in the 'mistral' repo.
* Minor style changes.

Change-Id: Ia3f50388638d68bbcc5e2e9e424ddb9dd65b26eb
2020-06-04 18:26:45 +07:00
Renat Akhmerov 44a2738460 Add a utility for JSON serialization
* This patch adds a utility that helps serialize data into a JSON
  string that might contain some non-standard data types like
  generators iterators and frozen dicts coming from YAQL. The
  utility uses oslo.serialization project that already takes care
  of iterators and any kinds of custom dicts. And in addition, it
  handles generators (assuming a generator represents an iterable
  similar to an iterator).
* Unit tests.
* Added YAQL into requirements and bumped the version of
  oslo.serialization to make sure to have the "fallback" parameter
  in "jsonutils.to_primitive"

Change-Id: I2fe891525bc86beb92aecf9ac2d8a490837c47d3
2020-03-31 18:33:05 +07:00
Eyal 237a10d22e Support getting a file list from a module that isn't mistral
Change-Id: I3157f9de4f2905dbc4f77257abbbc9f65093a63b
2020-02-26 09:44:56 +02:00
Eyal 1a81f2cdd8 Drop py2 support and add zuul jobs
Should be done with a major bump version e.g 2.0.0
Add docs and release zuul jobs

Change-Id: I2ff9881cf074b8d5bc052b1652dbc79b58ac586b
2020-01-28 14:05:12 +02:00
Eyal 77e640fe76 Move inspect utils to mistral-lib
Used also in mistral-extra so let move it to here

Change-Id: Ifa60374818ff3fe6da649d04c84c832b313e90d7
2020-01-21 15:19:10 +02:00
Eyal 1c3a3f2248 Update hacking and fix warning
Change-Id: If1358bcfc3f914956f8917cbbcea894f6264febc
2020-01-07 14:58:46 +02:00
Zuul 283e064a4c Merge "Wrong call to super" 2019-11-06 04:57:32 +00:00
Cédric Jeanneret f51d2a21c0 Ensure we mask sensitive data from Mistral Action logs
Mistral didn't make use of the oslo_utils "mask_password" methods,
leading in sensitive data leakage in its logs.

This patch corrects this security issue.
Note that it depends on oslo_utils patch adding new patterns, and
ensuring it's case-insensitive.

Change-Id: I544d3c172f2dea02c62c49c311c4b5954413ae15
Related-Bug: #1850843
Co-Authored-By: Dougal Matthews <dougal@redhat.com>
Signed-off-by: Cédric Jeanneret <cjeanner@redhat.com>
2019-11-05 10:35:16 +00:00
Eyal 85022089b2 Wrong call to super
Change-Id: If3d3b044a0455000c80bea4e6240ad98d74cc540
2019-10-30 14:20:44 +02:00
ali 070080bd1b moved generic util functions from mistral to mistral-lib
Change-Id: I780c270e4b1a184d7d4dcc580d23697ba75edab1
Closes-bug: #1815183
2019-08-08 07:35:45 +00:00
Dougal Matthews 9f5162fa5a Make the ActionContext serializable
Currently if Mistral needs to pass the ActionContext  via it's internal
rpc calls it wont be serialised. This change should have no end-user
impact, but makes it easier for Mistral to use internally.

Change-Id: I238355d52c77d622740527e43ddb2b7484cc58db
2018-07-24 14:43:29 +01:00
Ifat Afek d1ccfd0555 Fixed the documentation of 'run' params
The description of the 'context' param was inaccurate

Change-Id: I8c483102eb787dc4d4b7fcff746cb525c2e3b09a
2018-06-27 15:11:04 +00:00
sunqingliang6 fb8f4e3ce6 fix the method description, wrong grammar
Change-Id: I6dbb40ada4b6a9ab12a0291dedd62718f76baae0
2018-01-16 14:03:16 +08:00
guotao ae4fa908cf Fix the method description
Fix the method description in serialization.py

Change-Id: I8553f5f1c6917cd6ebde00a9ce70c3af7edd9572
2018-01-16 09:04:03 +08:00
Dougal Matthews 817461b40c Provide redirection for all security context attributes
The previous attempt at this was to redirect as little as possible.
However, this has proven to be problematic twice. auth_cacert wasn't
redirected, it was used by some of the OpenStack actions and thus
blocked Mistral [1] patch that would have Mistral start using the new
context.

This change redirects all properties in the SecurityContext which should
be safer for our internal actions and for end users actions.

[1]: https://review.openstack.org/#/c/506185/14

Partial-Bug: #1718353
Needed-By: Ife653558bfcda794e7f37086832f70b0ad7c28a4
Change-Id: I6057d0ce3fe4ae23468be8fb06cb85dc5f467f6b
2017-11-09 11:39:33 +00:00
Dougal Matthews 40e593bd20 Rename task_id to task_execution_id
The previous name isn't consistent and it is confusing, tasks don't have
an ID, but the execution for a task does.

Related-Bug: #1718353
Change-Id: I049cf7312c58d83e9405aaa36a6961cca006cb16
2017-10-30 09:04:31 +00:00
Dougal Matthews e195c6d90f Add deprecated context parameters to the new security context
In the recent parameter migration, a number of parameters were
incorrectly deprecated. They were not redirected to the new location
correctly and would cause an error.

Change-Id: I5ea09c3c79df5a43b06194a48f7425a15a1b23cf
Closes-Bug: #1728081
2017-10-30 08:34:21 +00:00
Dougal Matthews ff1e58332f Add an empty __init__ method to the base Action class
Without this, the action loading will fail in Python 2 if the action
subclass doesn't define a __init__.

Closes-Bug: #1724594
Change-Id: I7cf9fdc9446462c7f5010d0ba8b307b05656704e
2017-10-18 15:51:47 +01:00
Dougal Matthews db09c50dbe Add a representation of the ActionContext in mistral-lib
This allows us to better define the expected interface and provide
additional context information to actions.

The existing context is deprecated with this change and will output
deprecation warnings for the old property names.

Change-Id: Ib879ba58d4b9a04d4f5ea668ae94d79a82758919
Partial-Bug: #1718353
2017-10-04 09:46:54 +00:00
Renat Akhmerov e4b9b5543f Update serialization from 'mistral' repo with latest changes
Note: We need to switch to 'serialization' from 'mistral-lib' as soon
as we switch 'mistral' to use 'mistral-lib'.

Change-Id: I608ba7abb097d19cce3d20c48e1669fa4b96dc77
2017-05-03 11:31:07 +07:00
Dougal Matthews b5066c3c56 Remove the unused ApplicationContextNotFoundException
Change-Id: I3ac12ee4a7d7369ac7f59b969b0ca07b4752b3b5
2017-04-25 14:47:36 +01:00
Dougal Matthews c0982f4797 Make the Result class more convienient to use
Action was added to mistral_lib.actions to make it simpler to use.
However, generally you also need the Result class. This adds it in the
same place, so actions developers only need to import one module to
access both classes.

Change-Id: I51ae3440ac62ebad5ae13a5e3edf01df66af71c7
2017-04-19 10:08:21 +01:00
Ryan Brady 5764aec7ae Adds minimum common shared code for custom actions API
This patch includes the initial data types, serialization,
string utilities, base exception classes and defines a
base action that includes a context argument.

The mistral_lib.api namespace was also removed in favor of
following the python convention of using an underscore to
denote private methods and considering all other methods
public.

This patch removes code previously added as a placeholder
to match the spec.  As of the Atlanta PTG, the purpose of
this library is now to store common code used within Mistral
ecosystem and 3rd party integration interfaces including
the Custom Actions API and Custom YAQL Functions API.

Change-Id: I77da3cd6eba6c5a9953656d432bc959bd3747ada
Partially-Implements: blueprint mistral-custom-actions-api
Partially-Implements: blueprint mistral-actions-api-main-entities
2017-03-14 10:14:03 -04:00
Ryan Brady 6a6620bc48 Fixes namespace issue
This patch renames the mistral directory to mistral_lib to ensure
an action would not hit a namespace issue when attempting to import.
e.g. "from mistral import context".

Change-Id: I984b6a9569aef9e9f52fb3c037ff133081b7d933
2016-07-15 09:29:11 -04:00