Context attributes in events for event engine

Bug #1857112 reported by ITD27M01
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Mistral
New
Undecided
Unassigned

Bug Description

We use the event engine for managing DNS records with Designate service. To create "PTR" records for each "A" record, the following event trigger used:

{
  "Workflow ID": "feb60678-669f-458f-bca0-ea39dd7bdb8a",
  "Exchange": "designate",
  "Event": "dns.recordset.create",
  "Topic": "notifications",
  "Params": "{}",
  "Updated at": null,
  "ID": "414be2c6-b692-42b9-a745-842955a54138",
  "Created at": "2019-12-18 16:42:16",
  "Name": "cloud.events.dns.create_ptr"
}

Here is an example of event_definitions.yaml for such events:

cat /etc/mistral/event_definitions.yaml
- event_types:
    - dns.*
  properties:
    event: <% $ %>
    project_id: <% $.context.project %>
    user_id: <% $.context.user %>

The problem is context from service has attributes <user> and <project> but not <user_id> and <project_id> [1], [2], [3]. Here is an example of an event:

        "event": {
            "publisher": "central.172.30.0.134",
            "context": {
                "domain": null,
                "project_domain": null,
                "auth_token": "gAAAAABd_Jfa9ELieG6_mXivzbdkTqaprOKRzAXYvQH0NXyD8AKfbqJ22ppjtTHg26wrln8TCLJWscHsv8YowSfQl70Fs9NBSdgrCqJ-BFTTqvDMPfLXLWnLcevK4CCrPWW7dsKllRGvs3KqWkQSnVBtoDj4Wy6QZKuIKtKJIPMgv35Su70-pmSg5VUCkkVHLqVcfOT1wx4z",
                "resource_uuid": null,
                "original_tenant": null,
                "read_only": false,
                "system_scope": null,
                "user_identity": "ad64ce5e9890b9596163edd10c8a4da2bca62c4f84f720b59cf30d20903c60ab 975d866668854d14b6cb37d6a9780172 - - -",
                "is_admin_project": true,
                "hide_counts": false,
                "client_timeout": null,
                "global_request_id": null,
                "is_admin": false,
                "user": "ad64ce5e9890b9596163edd10c8a4da2bca62c4f84f720b59cf30d20903c60ab",
                "service_catalog": []
                "tsigkey_id": null,
                "all_tenants": false,
                "tenant": "975d866668854d14b6cb37d6a9780172",
                "show_deleted": false,
                "roles": [
                    "admin"
                ],
                "edit_managed_records": false,
                "client_addr": "172.30.44.64",
                "project": "975d866668854d14b6cb37d6a9780172",
                "request_id": "req-a272bad3-8621-401f-9584-11f7dcfb715c",
                "abandon": null,
                "user_domain": null
            },
            "event_type": "dns.recordset.create",
            "timestamp": "2019-12-20 09:43:59.434517",
            "payload": {
                "zone_id": "70a6c3e9-fbd7-4b9a-beb5-841046754de3",
                "tenant_id": "975d866668854d14b6cb37d6a9780172",
                "created_at": "2019-12-20T09:43:59.393688",
                "description": "None",
                "updated_at": null,
                "records": [
                    {
                        "status": "PENDING",
                        "zone_id": "70a6c3e9-fbd7-4b9a-beb5-841046754de3",
                        "managed": false,
                        "managed_resource_id": null,
                        "managed_resource_type": null,
                        "tenant_id": "975d866668854d14b6cb37d6a9780172",
                        "created_at": "2019-12-20T09:43:59.405292",
                        "managed_extra": null,
                        "updated_at": null,
                        "managed_plugin_type": null,
                        "version": 1,
                        "managed_plugin_name": null,
                        "managed_tenant_id": null,
                        "action": "CREATE",
                        "hash": "0ee96e7ffa25e0a81485d7200bc55e11",
                        "managed_resource_region": null,
                        "recordset_id": "440305dc-f31a-4c0e-abbb-e626f3beec5b",
                        "data": "srv8-jobscdc.delivery.cloud",
                        "id": "2d0acbcb-b5f6-4a10-adee-b8c5c7b1b02b",
                        "serial": 1576835039,
                        "description": null
                    }
                ],
                "version": 1,
                "ttl": null,
                "zone_name": "176.30.172.in-addr.arpa.",
                "type": "PTR",
                "id": "440305dc-f31a-4c0e-abbb-e626f3beec5b",
                "name": "213.176.30.172.in-addr.arpa."
            }
        }

As a result, the trigger cannot start the workflow because default_event_engine cannot match the context with the event trigger owner.

[1] https://github.com/openstack/mistral/blob/master/mistral/event_engine/default_event_engine.py#L295
[2] https://github.com/openstack/mistral/blob/master/mistral/event_engine/default_event_engine.py#L44
[3] https://github.com/openstack/mistral/blob/master/mistral/event_engine/default_event_engine.py#L45

ITD27M01 (igortiunov)
description: updated
Revision history for this message
ITD27M01 (igortiunov) wrote :

The example context for compute.instance.create.end event (both project and project_id are present):

        "context": {
            "domain": null,
            "project_domain": "95ab4645f0764ac782765cbdcc79bbff",
            "auth_token": "",
            "resource_uuid": null,
            "read_only": false,
            "user_id": "bbe117ded750704ba460feaabff6190c6b07c9acabc91066878cfca0c8362f48",
            "system_scope": null,
            "user_identity": "bbe117ded750704ba460feaabff6190c6b07c9acabc91066878cfca0c8362f48 40e5d3f91fb44ccaa9056252efc243a7 - 95ab4645f0764ac782765cbdcc79bbff 95ab4645f0764ac782765cbdcc79bbff",
            "is_admin_project": true,
            "tenant": "40e5d3f91fb44ccaa9056252efc243a7",
            "project_id": "40e5d3f91fb44ccaa9056252efc243a7",
            "user_name": "my_user",
            "client_timeout": null,
            "project_name": "my_project",
            "global_request_id": null,
            "timestamp": "2020-03-16T07:58:10.676305",
            "remote_address": "172.30.202.28",
            "quota_class": null,
            "is_admin": false,
            "user": "bbe117ded750704ba460feaabff6190c6b07c9acabc91066878cfca0c8362f48",
            "service_catalog": [
            ],
            "read_deleted": "no",
            "show_deleted": false,
            "roles": [
                "user"
            ],
            "project": "40e5d3f91fb44ccaa9056252efc243a7",
            "request_id": "req-80c91d5b-2b22-4aca-800e-e27cf65949f1",
            "user_domain": "95ab4645f0764ac782765cbdcc79bbff"
        }

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.