Commit Graph

61 Commits

Author SHA1 Message Date
Zuul 431ece5581 Merge "Info endpoint" 2023-05-17 09:05:03 +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
Arnaud Morin 70af40becc Remove tenant when building mistral context
When building mistral context (using oslo.context) from environment, the
tenant extra key was given, which is not accepted by oslo.context.

This issue was detected when debugging a mistral-client test:
mistralclient.tests.functional.cli.v2.test_cli_v2.NegativeCLITests.test_target_action_execution

Signed-off-by: Arnaud Morin <arnaud.morin@ovhcloud.com>
Change-Id: I72ce8851ea5b379a8af75b32fb600691638836af
2023-01-18 21:20:28 +01: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
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
Renat Akhmerov c888a46ccc Fix keycloak authentication
* Implement offline access token validation using Keycloak public key.

Closes-bug: #1857871
Change-Id: I0eecec4b4e64381cac005622b16c6d9e4bed4df6
2020-01-14 15:51:06 +07: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
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
Brad P. Crochet 0085d08baa Stop using deprecated keystone_authtoken/auth_uri
keystone_authtoken/auth_uri is deprecated [1]. Use www_authenticate_uri
instead.

keystonemiddleware in requirements and lower constraints should be increased
because www_authenticate_uri was introduced in keystonemiddleware 4.18.0.

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

Change-Id: I99b0ee941d702a28fb4f392d9747d0e2257a42c8
Closes-Bug: #1788174
2019-02-19 10:37:23 +00:00
Dougal Matthews b16a4ce465 Explicitly convert X-Target-Insecure to a boolean
We will now only accept the string values "False" or "True". Previously
any given value was interpreted as a string and thus True.

Closes-Bug: #1666565
Change-Id: Ibd105c881dbe16cd4516bfb775c8f5f43c961b45
2018-08-22 09:48:30 +01:00
Renat Akhmerov 7b71f096b9 New experimental scheduler: the first working version
This patch delivers the first working version of a distributed
scheduler implementation based on local and persistent job
queues. The idea is inspired by the parallel computing pattern
known as "Work stealing" although it doesn't fully repeat it
due to a nature of Mistral.
See https://en.wikipedia.org/wiki/Work_stealing for details.

Advantages of this scheduler implementation:

* It doesn't have job processing delays when a cluster topology'
  is stable caused by DB polling intervals. A job gets scheduled
  in memory and also saved into the persistent storage for
  reliability. A persistent job can be picked up only after a
  configured allowed period of time so that it happens effectively
  after a node responsible for local processing crashed.
* Low DB load. DB polling still exists but it's not a primary
  scheduling mechamisn now but rather a protection from node crash
  situations. That means that a polling interval can now be made
  large like 30 seconds, instead of 1-2 seconds. Less DB load
  leads to less DB deadlocks between scheduler instances and less
  retries on MySQL.
* Since DB load is now less it gives better scalability properties.
  A bigger number of engines won't now lead to much bigger
  contention because of a big DB polling intervals.
* Protection from having jobs forever hanging in processing state.
  In the existing implementation, if a scheduler captured a job
  for processing (set its "processing" flag to True) and then
  crashed then a job will be in processing state forever in the DB.
  Instead of a boolean "processing" flag, the new implementation
  uses a timestamp showing when a job was captured. That gives us
  the opportunity to make such jobs eligible for recapturing and
  further processing after a certain configured timeout.

TODO:

* More testing
* DB migration for the new scheduled jobs table
* Benchmarks and testing under load
* Standardize the scheduler interface and write an adapter for the
  existing scheduler so that we could choose between scheduler
  implementations. It's highly desired to make transition to the
  new scheduler smooth in production: we always need to be able
  to roll back to the existing scheduler.

Partial blueprint: mistral-redesign-scheduler
Partial blueprint: mistral-eliminate-scheduler-delays

Change-Id: If7d06b64ac14d01e80d31242e1640cb93f2aa6fe
2018-08-14 14:02:19 +07:00
Dougal Matthews fe6f0c5c34 Migrate mistral to using the serialization code in mistral-lib
We previously ported the code to mistral-lib, but Mistral has been using
the original copy.

Closes-Bug: #1782765
Change-Id: Ifb518d821097fdf2ec76161ae00f312ced19c272
2018-07-23 12:55:41 +01:00
Idan Narotzki 1ece440ac5 Adding WWW-Authenticate info.
Sometimes when mistral requests are failing with "401 Unauthorized"
against keycloak, the reason are not mentioned in the logs.

In case keycloack return 401 it must provide the www-Authenticate
response header with the reason:
https://www.w3.org/Protocols/HTTP/1.0/spec.html#WWW-Authenticate

This code take care of it by adding the WWW-Authenticate value to
mistral api-log.

Change-Id: I7ae221aaeb2233184bd4818490e72ff662dca5cb
Closes-Bug: #1737500
2018-04-11 07:24:46 +00:00
Steven Hardy 6b81707ce1 Add missing user/project name in action context
These were removed in Ife653558bfcda794e7f37086832f70b0ad7c28a4
but that breaks any actions which require this data, such as
some TripleO actions.

Closes-Bug: 1740891
Change-Id: I777b1f7c7012b735805e8585938b5ce5dec31d26
2018-01-02 17:56:05 +00:00
Dougal Matthews dd4a4bd440 Pass the new ActionContext to mistral-lib
Partial-Bug: #1718353
Depends-On: I6057d0ce3fe4ae23468be8fb06cb85dc5f467f6b
Change-Id: Ife653558bfcda794e7f37086832f70b0ad7c28a4
2017-12-11 22:42:48 +00:00
Thomas Herve a944cdb98e Don't use oslo context get_logging_values
get_logging_values has been changed recently to not pass the token
anymore, call to_dict as expected.

Change-Id: I3a7f1293a4d0082274af270f86b5c732d898f8bc
Closes-Bug: #1733345
2017-11-24 14:52:42 +01:00
Lingxian Kong 14978c2352 Refactor mistral context using oslo_context
Also, using oslo.context coordinated with oslo.log will provide more
information in the log.

See more information here:
http://openstack.markmail.org/thread/kuvzwhtblwhoz6o5

Co-Authored-By: Lingxian Kong <anlin.kong@gmail.com>
Change-Id: I1f3f4c1546a85129af1bd58ead9132780909f0d3
2017-06-23 10:34:40 +12:00
Sharat Sharma 7664c5d2a1 Remove unused logging import
Change-Id: I6205e7d49277871323f1ff937bd62a14a5e0a788
2017-05-11 11:45:13 +00:00
Emilien Macchi 2a2c8e733b Revert "Support transition to keystone auth plugin"
This patch broke Ironic introspection workflow:
https://bugs.launchpad.net/tripleo/+bug/1688767

This reverts commit 1c485867c4.
Related-Bug: #1688767

Change-Id: I86d4b40e19b3b0b3cfe0d30e2c5a588e29af6d98
2017-05-09 13:02:12 +00:00
Brad P. Crochet 1c485867c4 Support transition to keystone auth plugin
The puppet module puppet-mistral is moving to use a proper keystone
authtoken module. This supports that transition. A follow on patch
will remove the transition code.

Change-Id: Ief32ae01372c8c8d32fc5e2c89a2927510983a5b
2017-05-04 17:40:55 -04:00
Renat Akhmerov 93ed2099d1 Refactor RPC serialization: add polymophic serializer
* The initial driver of this effort was that, as it turned out,
  it was impossible to have custom serialization for a custom
  type. For example, we had class Result and even had
  ResultSerializer but it wasn't used. So after taking a closer
  look it became clear that our serialization subsystem did not
  allow to register any alternative serializers by design.
  Because we had to use one serializer implementation registered
  in RPC. The solution is to make it more flexible by adding
  a special router-like serializer that knows to which specific
  serializer it needs to switch depending on an object type.
* Refactored serialization subsystem so that it's more flexible
  and manageble
* Added polymorphic entity serializer that can work as a router
  and switch between different serializers depending on their type
* Used Result and ResultSerializer in RPC instead of decomposing
  result object into primitive fields explicitly

Co-Authored-By: Dawid Deja <dawid.deja@intel.com>
Change-Id: I29d40a0b1b68a5410f3db2f7280c9c6244d55a84
2017-02-14 13:19:43 +07:00
Renat Akhmerov c30b3bfd26 Refactor RPC serialization: remove JsonPayloadSerializer class
* This class is not needed in Mistral, we can use the exact same
  class from oslo.messaging
* Changed RpcContextSerializer to use JsonPayloadSerializer by
  default so that we don't have to pass it as a parameter
  every time

Change-Id: Ic4ad92cb732c33e6d1971b50076afde219147536
2017-02-03 14:16:55 +07:00
Istvan Imre 600dd47654 Insecure flag added to openstack context
New Insecure flag inroduced for openstack actions. With that mistral
is able to connect to https clouds without verifying server certificate.

Change-Id: If7839ac586ff0b50f3f323a6bd42349eb0c25ca8
2017-01-12 08:18:16 +00:00
Lingxian Kong 965db538aa Role based resource access control - get workflows
We already supported role based api access control, this series patches
will implement resource access control for mistral, so that
administrator could define the rules of resource accessibility, e.g.
admin user could get/delete/update the workflows of other tenants
according to the policy.

TODO:
- Implement update workflow by admin
- Implement delete workflow by admin
- Implement for other resources(workfbook/execution/task/action, etc.)

Partially implements: blueprint mistral-rbac

Change-Id: I8b00e8a260a74457ad037ee7322a7cba9ae34fab
2016-12-22 14:12:33 +13:00
Istvan Imre 603cd4808c Handle region_name in openstack actions
User now could define the region for the openstack actions.
It could be done via API in X-Region-Name and X-Target-Region-Name
in case of multi-vim feature is used.

*API change*
X-Region-Name: Header added to execution create
X-Target-Region-Name: Header added to execution create

Change-Id: Icbf63962a481c1282b95359894fa6245e0e97bac
Related-Bug: #1633345
2016-11-08 15:30:00 +01:00
Lingxian Kong bffb2476e7 Use service catalog from authentication response
When using Mistral in multi openstack deployments, user can pass
'X-Target-Auth-Uri' in the header to let Mistral run openstack service
actions in different openstack deployment. 'X-Target-Service-Catalog'
can also be provided but it's optional.

This patch adds 'is_target' attribute to Mistral context, if it's true,
Mistral will talk to another openstack deployment, 'service_catalog'
in the context can be empty or contain target service catalog provided
by user, Mistral will get service catalog dynamically if it's empty;
if it's false, the 'service_catalog' in context can also be empty(when
auth_enable=False) or the content that get from keystone authentication
response.

This patch also fix the tempest failure introduced by:
https://review.openstack.org/#/c/387883/

Related-Bug: #1634090
Change-Id: Iec3ed0333cd08831f0a15f77e3880f07dd89e1e8
2016-10-28 10:05:38 +00:00
Fei Long Wang b766e0dcda Get service catalog from token info
Closes-Bug: #1634090
Change-Id: I661bdbc4c70b17523d156eedc33aef32ddacf84f
2016-10-19 23:23:12 +00:00
Andras Kovi 9ebf329aa0 Accept service catalog from client side
Updates the Mistral server to accept the service catalog
from the client request. This enable the server to cooperate
with Keystone Identity V2 and V3 at the same time.

Change-Id: I7ca2aace4d5095828e5053af6965b833109d338a
Closes-Bug: #1612705
Depends-On: I86fa58de00d01c89e4bbc21dbe128f1306e2a1bf
Signed-off-by: Andras Kovi <akovi@nokia.com>
2016-09-28 13:27:08 +02:00
Jenkins 1281036a81 Merge "Remove context.spawn" 2016-09-19 11:41:48 +00:00
Thomas Herve 7d03d18d55 Remove context.spawn
The spawn function in the context module is broken and isn't used, let's
remove it.

Change-Id: I9c88651a42515d6da7836cd72c24c0c719f31728
2016-09-19 12:02:34 +02:00
Winson Chan f9c9ca8260 Abstract authentication function
Abstract authentication function so plugins for other authentication
backends can be implemented in cases where keystone is not used. Currently,
mistral is hard coded to support keystone and keycloak. The domain/project
related trust that is specific to keystone is not addressed.

Change-Id: I21994ab20af519b2ba85efd7cbe043547988e5b3
Implements: blueprint mistral-abstract-auth
2016-09-15 23:37:30 +00:00
Nikolay Mahotkin 3958a82df1 Fix getting URLs / and /v2
* This is the reason why mistralclient tests
   are failing.

Closes-Bug: #1619628

Change-Id: I1b61bd1de6811a5f65c2375dde956aafe33445b2
2016-09-02 14:30:50 +03:00
Shaik Apsar 9a60c02b77 Fix for 'Cannot authenticate without an auth_url'
Only Mistral Cron execution failing to get endpoint
for the OpenStack Services.

Change-Id: I985a8d21fe48b488eb7e452d31b016e8239a5752
Closes-Bug: 1607788
2016-08-30 04:23:48 -04:00
Jeff Peeler 347aabc1e5 Add client caching for OpenStack actions
This change adds caching for all the actions. When an action request
is made, the cache is checked to see if a client has already been
created. If an existing client is found, the keystone token expiration
is verified to still be current within the configurable window. Once a
client's token becomes invalid a new client is created and the cache
is refreshed.

The new configuration option for setting the token expiration window
is expiration_token_duration present in the default section.

Change-Id: I854f0251d9ec3623700d8a4025df8f1bc632a3e9
2016-08-29 17:47:50 -04:00
Andras Kovi b8c7dd755d Add target parameters to REST API
Adds the Target-* parameters to the REST API.

Implements: blueprint mistral-multi-vim-support
Change-Id: I51d065335df3a69fbf31fd9934b7bdc327df105f
Signed-off-by: Andras Kovi <akovi@nokia.com>
2016-08-02 15:40:51 +02:00
Dawid Deja 2197126489 Executor fails actions if they are redelivered
With this change executor will fail actions that are redelivered
and have flag safe_rerun set to false

Implements blueprint mistral-task-delivery-model

Change-Id: Ie0e728cf59af9fe44c8fd1d243439a82d9478ff4
2016-07-21 15:30:15 +02: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
Andras Kovi 998f5158e1 Use client credentials to retrieve service list
Credentials received in the request are used to retrieve endpoint
list from keystone. This avoids the usage of the admin creds
and opens the gate towards connecting to any clouds without
previous configuration.

Implements: blueprint mistral-multi-vim-support
Change-Id: Ib5ae5911f2535f4f340af8f4bcb4817818747029
2016-06-22 16:08:17 +02:00
Winson Chan 45ac6d03b1 Enable osprofiler to measure performance
Add option to enable osprofiler to measure performance of workflow execution.

Change-Id: I98e66e3f721c134370848dc2b65fb37c49b0e8ee
Implements: blueprint mistral-osprofiler
2016-06-10 01:49:38 +00:00
Lingxian Kong 6d07c3e6b6 Delivering error message via header in pecan.abort
This patch correlates with [1] in client side, when authentication
failed, the error message should be delivered to client side.

[1]: https://review.openstack.org/232395

Change-Id: I6a6ced466c05849fd9ff3dcd8377a57c9e9b595f
Closes-Bug: #1502840
2015-10-08 08:43:16 +00:00
Nikolay Mahotkin e523f7537c Making / and /v2 URLs allowed without auth
Closes-Bug: #1473963

Change-Id: I7170121a1216d9d72a43e552db1864a58e4c6237
2015-07-17 12:19:26 +03:00
LingxianKong 645576e2f0 Get rid of openstack/common package
* use oslo graduated modules, delete openstack/common package since there
  is no dependency on oslo-incubator modules now.
* delete openstack-common.conf for the reason above.
* update project requirements automatically.

Change-Id: I80610cbfe7fd54263c8a2d9178ec9a2498c91899
Closes-Bug: #1459188
2015-06-24 16:49:06 +08:00
Doug Hellmann 506800208a Drop use of 'oslo' namespace package
The Oslo libraries have moved all of their code out of the 'oslo'
namespace package into per-library packages. The namespace package was
retained during kilo for backwards compatibility, but will be removed by
the liberty-2 milestone. This change removes the use of the namespace
package, replacing it with the new package names.

The patches in the libraries will be put on hold until application
patches have landed, or L2, whichever comes first. At that point, new
versions of the libraries without namespace packages will be released as
a major version update.

Please merge this patch, or an equivalent, before L2 to avoid problems
with those library releases.

Blueprint: remove-namespace-packages
https://blueprints.launchpad.net/oslo-incubator/+spec/remove-namespace-packages

Change-Id: I73addc2c144c76c60f046e83c97e3b6ffe09d879
2015-06-22 20:02:59 +00:00
Kirill Izotov 5111543a5c Add mistral-db-manage script
Implements: blueprint mistral-manage-db-script

Co-Authored-By: Nikolay Mahotkin <nmakhotkin@mirantis.com>

Change-Id: If8465033e14af223bd5fea0b9ca9383e29db21c4
2015-04-01 13:29:25 +03:00
Nikolay Mahotkin bb56092316 Fix OS action client initialization
* Fix work with trust-scoped token
 * Fix NovaAction and KeystoneAction
 * Added new field to MistralContext - is_trust_scoped

Change-Id: Id1a8c959ffd07032f9ab03e5fdbafbdc66374ce3
2015-02-18 18:22:43 +03:00
Renat Akhmerov 95cda57e36 Adding method for authentication based on config keystone properties
Change-Id: I283b5d851d6bc2d62e6ba6814b1d1b47f79715bc
2014-10-21 16:23:00 +07:00
Renat Akhmerov a4bc15550b Cleanup, refactoring and logging
Change-Id: I3c720b05403b6080e361ea0c2fa19267e5d05ab5
2014-10-14 17:37:02 +07:00
Renat Akhmerov f3b4b6cf61 Cleaning up obsolete TODOs and minor style changes
Change-Id: Ic5d7dbbec7d96b50df094394aabaa4c30de5f2c5
2014-09-25 14:33:18 -07:00
Renat Akhmerov bc85fbdac8 Implementing task execution infrastructure
* Implemented action calls
* Implemented subworkflow calls
* Adding executor interface and default implementation
* Unit tests
* Small refactoring in workflow handlers
* Creating all necessary RPC infrastructure
* Refactoring launch script
* Added __repr__() implementation to MistralContext
* Small fixes in old infrastructure

Change-Id: I134ea526c295ca9bda7214c5403a41966062ff79
2014-08-27 17:22:00 +07:00