Ad-hoc actions cannot reference env() in YAQL/Jinja expressions
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mistral |
Fix Released
|
Medium
|
Bob Haddleton |
Bug Description
Ad-hoc actions cannot reference env() in YAQL and Jinja expressions.
The AdHocAction methods _prepare_input() and _prepare_output() call expr.evaluate_
Sample workbook:
version: "2.0"
name: TestEnv
actions:
print_
input:
- message: bar
base: std.echo
base-input:
output: "<% $.message %>: <% env().foo %>"
print_
input:
- message: bar
base: std.echo
base-input:
output: '{{ env().foo }}'
workflows:
dump_
type: direct
input:
- dummy: null
tasks:
print_
action: print_env_yaql_msg
print_
action: print_env_jinja_msg
Executing this workflow produces the following exception:
mistral execution-create TestEnv.
+------
| Field | Value |
+------
| ID | 4a2ddd7c-
| Workflow ID | f734a15b-
| Workflow name | TestEnv.
| Description | |
| Task Execution ID | <none> |
| State | ERROR |
| State info | Failed to run task [error=Can not evaluate YAQL expression [expression=
| | {'state_info': None, 'accepted': False, 'output': {}, 'name': u'TestEnv.
| | 'RUNNING', 'created_at': '2017-05-15 00:27:17', 'runtime_context': {'index': 0}, 'updated_at': '2017-05-15 00:27:17', 'spec': {u'input': [{u'dummy': None}], u'tasks': |
| | {u'print_
| | u'print_
| | u'2.0'}, 'workflow_id': u'f734a15b-
| | 409d-4162-
| | -902a-f17f6f350
| | Traceback (most recent call last): |
| | File "/root/
| | task.run() |
| | File "/root/
| | return f(*args, **kwargs) |
| | File "/root/
| | self._run_new() |
| | File "/root/
| | return f(*args, **kwargs) |
| | File "/root/
| | self._schedule_
| | File "/root/
| | action.
| | File "/root/
| | self._prepare_
| | File "/root/
| | base_input_dict |
| | File "/root/
| | data[key] = _evaluate_
| | File "/root/
| | return evaluate(item, context) |
| | File "/root/
| | return evaluator.
| | File "/root/
| | cls).evaluate(
| | File "/root/
| | ", data=%s]" % (expression, str(e), data_context) |
| | YaqlEvaluationE
| | |
| Created at | 2017-05-15 00:27:17 |
| Updated at | 2017-05-15 00:27:17 |
+------
Changed in mistral: | |
assignee: | nobody → Bob Haddleton (bob-haddleton) |
status: | New → In Progress |
description: | updated |
description: | updated |
Changed in mistral: | |
milestone: | none → pike-2 |
importance: | Undecided → Medium |
Reviewed: https:/ /review. openstack. org/464677 /git.openstack. org/cgit/ openstack/ mistral/ commit/ ?id=a121aacbbcc a0ee08832d387ea fa2885de61f054
Committed: https:/
Submitter: Jenkins
Branch: master
commit a121aacbbcca0ee 08832d387eafa28 85de61f054
Author: Bob Haddleton <email address hidden>
Date: Mon May 15 10:40:59 2017 -0500
Update AdHoc Actions to support context data references
AdHoc actions can be defined using YAQL and Jinja2 expressions in the
same way as Tasks, but they could not access the associated context
data because the context was not available when the expression is
evaluated. This patchset passes the task and workflow context into
the AdHocAction object so that the inputs can be evaluated using the
available context, and the context data will be available for
reference.
Added a test to verify that the env() works in AdHoc Actions.
Change-Id: Ib95604d3d494a4 43e852bc7f5eee2 4f398b1648c
Closes-Bug: 1690158