upstream tasks calculation is wrong

Bug #1427933 reported by Winson Chan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mistral
Fix Released
High
Winson Chan

Bug Description

In the following example, the WF is straightfoward. The notify is a task executed after each tasks. On calculation of upstream tasks for notify, you'll see the number of upstream tasks for each call of notify include all previous tasks. Is this correct? Shouldn't it be only the immediate upstream task? Currently, this creates an error where merge dicts @ https://github.com/stackforge/mistral/blob/master/mistral/workflow/data_flow.py#L50 are stepping over each other.

diff --git a/mistral/workflow/data_flow.py b/mistral/workflow/data_flow.py
index b4f34cc..74523c4 100644
--- a/mistral/workflow/data_flow.py
+++ b/mistral/workflow/data_flow.py
@@ -45,6 +45,10 @@ def prepare_db_task(task_db, task_spec, upstream_task_specs, exec_db,
         upstream_task_specs
     )

+ LOG.info("[%s] NUM UPSTREAM TASKS: %s", exec_db.id, len(upstream_db_tasks))
+ for task in upstream_db_tasks:
+ LOG.info("[%s] UPSTREAM TASK FOR %s: %s", exec_db.id, task_db.name, task.name)
+
     task_db.in_context = utils.merge_dicts(
         copy.copy(exec_db.context),
         _evaluate_upstream_context(upstream_db_tasks)

~$ cat ~/tmp/test-upstream-tasks.yaml
version: "2.0"
name: "test-upstream-tasks"

workflows:

    main:
        type: direct
        input:
            - subject
            - adjective
        output:
            tagline: "{$.printed_subject} is {$.printed_adjective}!"
        task-defaults:
          on-error:
            - fail
        tasks:
            print_subject_1:
                action: std.echo
                input:
                    output: <% $.subject %>
                publish:
                    printed_subject: <% $.print_subject_1 %>
                    progress: "@print_subject_1"
                on-success:
                    - print_subject_2
                    - notify
            print_subject_2:
                action: std.echo
                input:
                    output: "This <% $.subject %> thing"
                publish:
                    printed_subject: <% $.print_subject_2 %>
                    progress: "@print_subject_2"
                on-success:
                    - print_adjective
                    - notify
            print_adjective:
                action: std.echo
                input:
                    output: <% $.adjective %>
                publish:
                    printed_adjective: <% $.print_adjective %>
                    progress: "@print_adjective"
                on-success:
                    - notify
            notify:
                action: std.echo output=<% $.progress %>

$ mistral workbook-create ~/tmp/test-upstream-tasks.yaml
Starting new HTTP connection (1): localhost
+------------+----------------------------+
| Field | Value |
+------------+----------------------------+
| Name | test-upstream-tasks |
| Tags | <none> |
| Created at | 2015-03-04 01:09:53.453036 |
| Updated at | None |
+------------+----------------------------+

$ mistral execution-create test-upstream-tasks.main '{"subject": "mistral", "adjective": "super buggy"}'
Starting new HTTP connection (1): localhost
+------------+--------------------------------------+
| Field | Value |
+------------+--------------------------------------+
| ID | 47d8a520-3ec2-4ba5-b3a3-49d25ba2761d |
| Workflow | test-upstream-tasks.main |
| State | RUNNING |
| Created at | 2015-03-04T01:10:31.502885 |
| Updated at | 2015-03-04T01:10:31.571226 |
+------------+--------------------------------------+

$ mistral execution-list
Starting new HTTP connection (1): localhost
+--------------------------------------+--------------------------+---------+---------------------+---------------------+
| ID | Workflow | State | Created at | Updated at |
+--------------------------------------+--------------------------+---------+---------------------+---------------------+
| 47d8a520-3ec2-4ba5-b3a3-49d25ba2761d | test-upstream-tasks.main | SUCCESS | 2015-03-04 01:10:31 | 2015-03-04 01:10:32 |
+--------------------------------------+--------------------------+---------+---------------------+---------------------+

$ sudo tail -n 1000 /var/log/mistral.log | grep 47d8a520-3ec2-4ba5-b3a3-49d25ba2761d | grep UPSTREAM
2015-03-04 01:10:31,524 139727930081520 INFO data_flow [-] [47d8a520-3ec2-4ba5-b3a3-49d25ba2761d] NUM UPSTREAM TASKS: 0
2015-03-04 01:10:31,746 139727923264080 INFO data_flow [-] [47d8a520-3ec2-4ba5-b3a3-49d25ba2761d] NUM UPSTREAM TASKS: 1
2015-03-04 01:10:31,746 139727923264080 INFO data_flow [-] [47d8a520-3ec2-4ba5-b3a3-49d25ba2761d] UPSTREAM TASK FOR print_subject_2: print_subject_1
2015-03-04 01:10:31,752 139727923264080 INFO data_flow [-] [47d8a520-3ec2-4ba5-b3a3-49d25ba2761d] NUM UPSTREAM TASKS: 2
2015-03-04 01:10:31,752 139727923264080 INFO data_flow [-] [47d8a520-3ec2-4ba5-b3a3-49d25ba2761d] UPSTREAM TASK FOR notify: print_subject_2
2015-03-04 01:10:31,752 139727923264080 INFO data_flow [-] [47d8a520-3ec2-4ba5-b3a3-49d25ba2761d] UPSTREAM TASK FOR notify: print_subject_1
2015-03-04 01:10:31,904 139727918671344 INFO data_flow [-] [47d8a520-3ec2-4ba5-b3a3-49d25ba2761d] NUM UPSTREAM TASKS: 1
2015-03-04 01:10:31,904 139727918671344 INFO data_flow [-] [47d8a520-3ec2-4ba5-b3a3-49d25ba2761d] UPSTREAM TASK FOR print_adjective: print_subject_2
2015-03-04 01:10:31,909 139727918671344 INFO data_flow [-] [47d8a520-3ec2-4ba5-b3a3-49d25ba2761d] NUM UPSTREAM TASKS: 3
2015-03-04 01:10:31,909 139727918671344 INFO data_flow [-] [47d8a520-3ec2-4ba5-b3a3-49d25ba2761d] UPSTREAM TASK FOR notify: print_subject_2
2015-03-04 01:10:31,909 139727918671344 INFO data_flow [-] [47d8a520-3ec2-4ba5-b3a3-49d25ba2761d] UPSTREAM TASK FOR notify: print_subject_1
2015-03-04 01:10:31,909 139727918671344 INFO data_flow [-] [47d8a520-3ec2-4ba5-b3a3-49d25ba2761d] UPSTREAM TASK FOR notify: print_adjective
2015-03-04 01:10:32,045 139727923265040 INFO data_flow [-] [47d8a520-3ec2-4ba5-b3a3-49d25ba2761d] NUM UPSTREAM TASKS: 3
2015-03-04 01:10:32,045 139727923265040 INFO data_flow [-] [47d8a520-3ec2-4ba5-b3a3-49d25ba2761d] UPSTREAM TASK FOR notify: print_subject_2
2015-03-04 01:10:32,045 139727923265040 INFO data_flow [-] [47d8a520-3ec2-4ba5-b3a3-49d25ba2761d] UPSTREAM TASK FOR notify: print_subject_1
2015-03-04 01:10:32,045 139727923265040 INFO data_flow [-] [47d8a520-3ec2-4ba5-b3a3-49d25ba2761d] UPSTREAM TASK FOR notify: print_adjective

$ mistral task-list
Starting new HTTP connection (1): localhost
+--------------------------------------+-----------------+--------------------------+--------------------------------------+---------+
| ID | Name | Workflow name | Execution ID | State |
+--------------------------------------+-----------------+--------------------------+--------------------------------------+---------+
| 0531f929-d2b0-45ee-a868-13f2e3da96ff | print_subject_1 | test-upstream-tasks.main | 47d8a520-3ec2-4ba5-b3a3-49d25ba2761d | SUCCESS |
| 30eab942-9273-4b8f-8c4e-5f7d5ca93af7 | notify | test-upstream-tasks.main | 47d8a520-3ec2-4ba5-b3a3-49d25ba2761d | SUCCESS |
| 96379ab6-d126-4943-a17d-f683c395e7ad | print_subject_2 | test-upstream-tasks.main | 47d8a520-3ec2-4ba5-b3a3-49d25ba2761d | SUCCESS |
| a832ab44-4f91-419a-a0e2-b4aca2b9c24c | print_adjective | test-upstream-tasks.main | 47d8a520-3ec2-4ba5-b3a3-49d25ba2761d | SUCCESS |
| bb0ed3e5-6956-42eb-919a-33932abcbd59 | notify | test-upstream-tasks.main | 47d8a520-3ec2-4ba5-b3a3-49d25ba2761d | SUCCESS |
| 3fe580fa-bc22-4e32-a34e-86c32d9dd236 | notify | test-upstream-tasks.main | 47d8a520-3ec2-4ba5-b3a3-49d25ba2761d | SUCCESS |
+--------------------------------------+-----------------+--------------------------+--------------------------------------+---------+

$ mistral task-get-input 3fe580fa-bc22-4e32-a34e-86c32d9dd236
Starting new HTTP connection (1): localhost
{
    "output": "@print_adjective"
}

$ mistral task-get-input bb0ed3e5-6956-42eb-919a-33932abcbd59
Starting new HTTP connection (1): localhost
{
    "output": "@print_subject_1"
}

$ mistral task-get-input 30eab942-9273-4b8f-8c4e-5f7d5ca93af7
Starting new HTTP connection (1): localhost
{
    "output": "@print_subject_1"
}

Changed in mistral:
milestone: none → kilo-3
importance: Undecided → High
status: New → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to mistral (master)

Reviewed: https://review.openstack.org/161552
Committed: https://git.openstack.org/cgit/stackforge/mistral/commit/?id=73010a88a88f55bc654687ca26f7f4dc8ca44b2f
Submitter: Jenkins
Branch: master

commit 73010a88a88f55bc654687ca26f7f4dc8ca44b2f
Author: Winson Chan <email address hidden>
Date: Thu Mar 5 23:08:52 2015 +0000

    Fix list of upstream tasks for task with no join

    Currently, if a task is referenced multiple times in the workflow,
    the upstream tasks identified are all the tasks that reference it.
    However, the upstream task should only be the immediate parent if
    there is no join in the task spec. If the task has a join, then the
    upstream tasks should only be all the immediate parents that end
    with the join and not every parent tasks that reference it. This
    patch only fixes task with no join.

    Change-Id: Iacf7cf5da3c91dea5412728624146873092d3686
    Closes-Bug: 1427933

Changed in mistral:
status: Confirmed → Fix Committed
Changed in mistral:
assignee: nobody → Winson Chan (winson-c-chan)
Changed in mistral:
status: Fix Committed → Fix Released
Changed in mistral:
milestone: kilo-3 → 2015.1
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.