Commit Graph

1842 Commits

Author SHA1 Message Date
Zuul 6e190e65ea Merge "Context versioning feature" 2024-03-14 13:03:26 +00:00
Oleg Ovcharuk f2cbe1c59d Context versioning feature
With complex parallel joins mistral had no mechanism to choose which
publish (left or right in terms of merge) should it use. It is a
common case when one branch updates existing value, but after merge
we see the old version.
This patch introduce context versioning feature, where every existing
key of mistral context has its version, and this version is used in
the context merge stage.

Change-Id: I604a9a8391150ac4801115b9892f781c33ecfdcb
Signed-off-by: Oleg Ovcharuk <vgvoleg@gmail.com>
2024-03-14 09:25:17 +00:00
Takashi Kajinami 44cd95684b Bump hacking
hacking 3.0.x is too old.

Also remove the note about pip's behavior which was already fixed in
recent versions.

Change-Id: I65d350943649c3346ed5741631c01724ddd256ef
2024-02-19 02:23:53 +09:00
Zuul 973e6ac996 Merge "Add optional healthcheck middleware" 2023-12-14 00:35:55 +00:00
Zuul 6a417dce53 Merge "Add checksum field to wf definition" 2023-12-13 23:31:55 +00:00
Zuul e38cfcbbdf Merge "Partial Workflow Failure Handling" 2023-12-13 23:23:35 +00:00
Vadim Zelenevsky 7cc007415b Partial Workflow Failure Handling
This feature introduces an enhanced error-handling
mechanism for workflows, allowing them to gracefully
handle issues within individual tasks without
causing a complete workflow failure. Previously,
when using subworkflow and passing an incomplete set
of parameters, the entire workflow would terminate.
With this feature, the workflow continues execution,
isolating errors at the task level. Consequently,
partial issues in one task no longer impact other
branches of workflow execution.

Implements blueprint partial-workflow-failure-handling

Change-Id: Id6a910c85c1d6953408682a2a724c4826333422f
2023-11-29 07:55:38 +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
Takashi Kajinami 6410ca6518 Avoid RuntimeError caused by iteration over sys.modules
As is described in the doc[1], we should not iterate over sys.modules
directly because sys.modules can be changed during iterations.

[1] https://docs.python.org/3/library/sys.html#sys.modules

Change-Id: Ib6ab36f93b408fdae59c1c08146f2ca069ed4f96
2023-11-28 01:12:35 +00:00
Zuul 7baff017d0 Merge "Fix test not waiting for action to be created" 2023-07-05 15:39:49 +00:00
Oleg Ovcharuk 5cb9cb74e5 Fix test not waiting for action to be created
Change-Id: I415bb3fbefa91da0e7aaca9fe5d3714989ffda69
Signed-off-by: Oleg Ovcharuk <vgvoleg@gmail.com>
2023-06-28 02:50:10 +03:00
Oleg Ovcharuk 6d3018ea01 Fix join task not refreshing inbound context
In error cases join task could lose context of some branches

Change-Id: I58a94c4ebc5d860473c9b48df326f6ea29cba9fa
Closes-Bug: #2020370
Signed-off-by: Oleg Ovcharuk <vgvoleg@gmail.com>
2023-05-24 18:16:59 +03:00
Vasudeo Nimbekar 9f52e2b6f3 Starting tasks via RPC
After this patch mistral will run tasks using RPC which will distribute tasks amongst available engine threads. this will enhance performance in case of executing huge executions containing multiple tasks.

Implements: blueprint distribute-mistral-operations

Change-Id: I0b7202589eee68ba5560bf2aa60fbbd6118f3719
2023-02-16 13:19:42 +05:30
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
Vasudeo Nimbekar 7c35734300 Merge mistral tasks data to execution context
after this patch user can choose option whether to replace or merge task data to the execution context.
ex: merge_strategy: replace/merge

Implements: blueprint merge-mistral-tasks-data
Change-Id: I3c96bab9953c4995f2b718ac48dff0f153872026
2023-01-31 17:27:17 +05:30
Zuul bfcc417044 Merge "Add an ability to hide sensitive data from http action logs" 2023-01-25 13:49:52 +00:00
Oleg Ovcharuk 3919e6a52b Add an ability to hide sensitive data from http action logs
Opportunity to hide sensitive data from http action logs, such as:
* Request headers
* Request body
* Response body

Change-Id: I6d1b1844898343b8fa30f704761096e3d2936c4d
Implements: blueprint mistral-hide-sensitive-data-from-http-actions-logs
Signed-off-by: Oleg Ovcharuk <vgvoleg@gmail.com>
2023-01-24 21:54:00 +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
Zuul 3554581cbe Merge "Fix race condition when comparing dates" 2022-09-09 12:49:25 +00:00
Zuul 540664346f Merge "Fix race condition when cancelling workflows" 2022-09-09 11:29:14 +00:00
Arnaud Morin b350f58f3e Fix race condition when comparing dates
A test is randomly failing due to a comparison between two dates:
created_at and started_at.
Most of the time these two dates are identical, but we can have one
second difference when the creation is done at the very end of a second
and the start is done at the beginning of the next one.

The fix is to make sure that we have less or equal than 1 sec between
started_at and created_at.

Signed-off-by: Arnaud Morin <arnaud.morin@ovhcloud.com>
Change-Id: I081bb659047f7639bed52dfac8b3858b10859404
2022-09-09 10:39:20 +02:00
Arnaud Morin 60c9dbf078 Fix race condition when cancelling workflows
Some tests which are cancelling workflows are also checking that only one task
was executed.
But the second task is delayed (wait-before: 3) so we can endup in a
situation when the second task appeared in the task_execs.

Signed-off-by: Arnaud Morin <arnaud.morin@ovhcloud.com>
Change-Id: I425b5ca0c1bedc22db1aa464f5f14aae69f9370e
2022-08-30 10:44:49 +02:00
Zuul 5881bcc466 Merge "Added sorting and marker for pagination of actions" 2022-08-24 07:18:54 +00: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
Takashi Kajinami 117f9a7945 Replace deprecated assertDictContainsSubset
The method is deprecated since Python 3.2[1] and shows the following
DeprecationWarning.

/usr/lib/python3.9/unittest/case.py:1134: DeprecationWarning:
assertDictContainsSubset is deprecated
  warnings.warn('assertDictContainsSubset is deprecated',

[1] https://docs.python.org/3/whatsnew/3.2.html#unittest

Closes-Bug: #1938103
Change-Id: I17f56606eb43fba46281e9bdc08ace8727455a40
2022-08-12 11:59:12 +00:00
Takashi Kajinami 3e07dcc424 Fix compatibility with oslo.context >= 4.0.0
The tenant argument of RequestContext is no longer available since
oslo.context >= 4.0.0 . This change fixes the compatibility issue
caused by that removal.

Note that this still keeps reference to 'tenant' argument to make
the code compatible with older oslo.context, but that can be removed
once oslo.context >= 4.0.0 becomes available in upper-constraints.

Change-Id: Ie671f50e5ff5a7c746f9e95691eaf4dd19937b52
2022-03-05 00:05:06 +09:00
Takashi Kajinami 55bb2564ac Use own util method(safe_load) to load yaml files
Since PyYAML 5.1, yaml.load without specifying the Loader option is
deprecated and shows the following warning.

YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated,
as the default Loader is unsafe.
Please read https://msg.pyyaml.org/load for full details.

This change replaces yaml.load by Mistral's own safe_load method which
is widely used to load yaml files.

Change-Id: I6cca093050c2ef696cf17174efc7b46330c10143
2022-03-02 09:29:15 +00:00
Takashi Kajinami b2d6de569c Fix unit test failures caused by type mismatch
Currently unit tests are failing because of the following type mismatch
detected.

testtools.matchers._impl.MismatchError: '{'k2', 'k1'}' is not an
instance of list

This change fixes that error.

Change-Id: I8ecedd341ba45d1919c9073dda8b2fc390306a52
2021-07-19 11:32:27 +09:00
songwenping 22e822dde2 Remove references to sys.version_info
We support Python 3.6 as a minimum now, making these checks no-ops.

Change-Id: Ia4b1eec7a788cb1ede3dc338f7be7e5d8a84069d
2021-07-10 06:20:08 +00:00
Takashi Kajinami de880e801c Fix unit test failures
This change fixes the following two patterns of errors detected in
gate.

1)
sqlalchemy.exc.ArgumentError: Textual column expression '...' should be
explicitly declared with text('...'), or use column('...') for more
specificity

2)
testtools.matchers._impl.MismatchError: '('...',)' is not an instance
of tuple

Change-Id: Ie080bdcacf9aa2dd2fe0454bcb814285c08bbfa8
2021-07-07 11:29:17 +09:00
Renat Akhmerov c00bf32ae4 Fix action heartbeat checker test
* With the recent update of the cachetools library the internal
  behavior of the cache became different and we made some assumptions
  in the test about how it should work. We did mocking for this.
  Now we have to modify it to reflect the latest behavior.

Change-Id: If76690481b5e0b88c034e35ef17657d59aaa4b4d
2021-01-14 18:12:55 +07: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 1d70823c6a Address a TODO comment in the legacy action provider test
* Added a test action generator to the test that checks the config
  option "load_action_generators".

Change-Id: I3ec465d5d9505a93850494d767668c021ef63847
2020-10-05 16:06:07 +07: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
Q.hongtao da5ac25415 Remove six.moves
Remove six.moves Replace the following items with Python 3 style code.
- six.moves.urllib
- six.moves.queue
- six.moves.range
- six.moves.http_client

Subsequent patches will replace other six usages.

Change-Id: I80c713546fcc97391c64e95ef708830632e1ef32
2020-09-22 08:34:20 +08:00
shenxindi f2392bae79 Use assertCountEqual instead of assertItemsEqual
The assertItemsEqual method has been removed in Python 3.3 [1] but
it was kept alive by unittest2, imported by testtools. For better
compatibility, change to assertCountEqual.

[1] https://bugs.python.org/issue17866

Change-Id: Ib025191bdc2762a9f920dd6c83e427d75d9a8d01
2020-07-21 10:30:55 +08:00
Renat Akhmerov 4f617856b6 Add a protection for list commands from parallel deletes
* While fetching a list of object in the REST layer we now check
  if the object has already been deleted in parallel (by catching
  the corresponding exception caused by lazy loading) and don't
  include it into the result set.
* Added the corresponding test that uses mocking and two synchronized
  threads to reproduce this corner case.
* Minor style changes.

Change-Id: Ia92d799a421e07542f270223c1add2aae7b32aab
Closes-Bug: #1887357
2020-07-16 13:13:55 +07:00
Renat Akhmerov 2ad7bb829b Moving task type constants into Mistral task specifications module
* There were references to Mistral specific constants mistakenly
  placed into mistral-lib. This patch adds these constants into
  the module where task language specifications are declared and
  changes the corresponding references.

Change-Id: I8c7c6896f01894ac76cf9365abfdce17e7df7662
2020-06-08 13:40:45 +07:00
Renat Akhmerov b55dbdea68 Refactor task notifications
* All calls to a notifier within the Task class have now been
  moved into the method set_state() so that the relation between
  a state change and a notification is now straightforward and the
  notification calls don't have to be spread out across different
  modules.

Change-Id: I9c0647235e1439049d3e7db13f19bef542f10508
2020-06-03 17:51:41 +07:00