task expression function throws exception if task wasn't executed

Bug #1631035 reported by Moshe Elisha
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Mistral
Fix Released
Medium
Renat Akhmerov

Bug Description

The function "task" is throwing an exception instead of returning null in case the task wasn't executed.

I was expecting something like “<% task(task2) != null %>” to work but I get the following error:

YaqlEvaluationException: Can not evaluate YAQL expression: task(task2) , data = {u'__task_execution': {u'id': u'4ed41a94-47db-4a0a-841a-e0ee1147684e', u'name': u'task1'}, u'__env': {}, u'__execution': {u'id': u'94885e19-995b-4ae1-bdd5-c326f7093f92'}}; error: Failed to find task execution with name: task2

For the below workflow:

version: '2.0'

workflow_test:
  type: direct

  output:
    task2: <% task(task2) %>

  tasks:
    task1:
      action: std.noop
      on-success:
        - task2: <% false %>

    task2:
      action: std.noop

Renat: "it's a bug. This function needs to return null if not found. It happens because we use db_api.get_task_execution() instead of db_api.load_task_execution() internally."

Changed in mistral:
milestone: none → ocata-1
assignee: nobody → Renat Akhmerov (rakhmerov)
importance: Undecided → High
status: New → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to mistral (master)

Fix proposed to branch: master
Review: https://review.openstack.org/383580

Changed in mistral:
status: Confirmed → In Progress
Changed in mistral:
importance: High → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to mistral (master)

Reviewed: https://review.openstack.org/383580
Committed: https://git.openstack.org/cgit/openstack/mistral/commit/?id=422def65a85aeae4edaceed512e4229746e4f9e6
Submitter: Jenkins
Branch: master

commit 422def65a85aeae4edaceed512e4229746e4f9e6
Author: Renat Akhmerov <email address hidden>
Date: Fri Oct 7 15:28:45 2016 +0700

    Change task() function to return 'null' if task doesn't exist

    * Before this change function task(task_name) available in Mistral
      expressions would fail with an error if such task doesn't exist.
      It makes impossible to have expressions like <% task(t1) != null %>
      which is very convenient in cases when we need to gather meta
      info about how a workflow was running and what tasks have already
      started and what have not. So now it simply returns 'null'.

    Change-Id: Ifd1ea9b5ee946c7072044d1402296710676845db
    Closes-Bug: #1631035

Changed in mistral:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/mistral 4.0.0.0b1

This issue was fixed in the openstack/mistral 4.0.0.0b1 development milestone.

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.