Nested AdHoc actions do not process all input defaults or output transformations

Bug #1711444 reported by Bob Haddleton
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mistral
Fix Released
High
Bob Haddleton

Bug Description

When using nested AdHoc Actions that use output transformations, the input defaults for the nested actions are not processed, and the action result is only being transformed by the output of the action that is being called. Output transformations in nested actions are not processed.

For example:

actions:
  concat_twice:
    base: std.echo
    base-input:
      output: "<% $.s1 %>+<% $.s2 %>"
    input:
      - s1: "a"
      - s2
    output: "<% $ %> and <% $ %>"

  nested_concat:
    base: my_wb.concat_twice
    base-input:
      s2: '{{ _.n2 }}'
    input:
      - n2: 'b'
    output:
      nested_concat: '{{ _ }}'

If concat_twice is called with s2='b', the output is "a+b and a+b"

So the expected output from nested_concat would be {"nested_concat": "a+b and a+b"}

But since the input defaults of concat_twice are not processed, and the output transform of the called action is the only one that is executed, the output transform in the concat_twice action is skipped and the output is:

{"nested_concat": "+b"}

The input defaults for each nested action can be processed in the existing traversal of nested action specs in _prepare_input(), instead of just processing the called action.

The output transformations can be processed with the same traversal of nested actions in the _prepare_output() method that is already being done in the _prepare_input() method, except that the order is reversed so that the base action output transform is processed first, and the called action output transform is called last.

    def _prepare_output(self, result):
        # In case of error, we don't transform a result.
        if not result.is_error():
            for action_def in reversed(self.adhoc_action_defs):
                adhoc_action_spec = spec_parser.get_action_spec(action_def.spec)

                transformer = adhoc_action_spec.get_output()

                if transformer is not None:
                    result = ml_actions.Result(
                        data=expr.evaluate_recursively(transformer, result.data),
                        error=result.error
                    )
        return result

Changed in mistral:
assignee: nobody → Bob Haddleton (bob-haddleton)
status: New → In Progress
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/494749

description: updated
summary: - Nested AdHoc actions do not process all output transformations
+ Nested AdHoc actions do not process all input defaults or output
+ transformations
Changed in mistral:
milestone: none → pike-rc2
importance: Undecided → Medium
importance: Medium → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to mistral (master)

Reviewed: https://review.openstack.org/494749
Committed: https://git.openstack.org/cgit/openstack/mistral/commit/?id=1cc8b24bfc381f345f9965c8401d3cf48d1ef1b9
Submitter: Jenkins
Branch: master

commit 1cc8b24bfc381f345f9965c8401d3cf48d1ef1b9
Author: Bob.Haddleton <email address hidden>
Date: Thu Aug 17 18:47:17 2017 -0500

    Process input defaults and output transforms for nested AdHoc Actions

    This change steps through all of the nested adhoc actions and processes
    the input defaults and output transformationss in order. The input
    defaults are processed starting with the called class, while the
    transforms are processed starting with the base class definition.

    Closes-Bug: 1711444
    Change-Id: I1873bd13f5424ac5eee8f5750a3fde4e02be1949

Changed in mistral:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to mistral (stable/pike)

Fix proposed to branch: stable/pike
Review: https://review.openstack.org/507295

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to mistral (stable/pike)

Reviewed: https://review.openstack.org/507295
Committed: https://git.openstack.org/cgit/openstack/mistral/commit/?id=943a0adfc778a3fa6c2c1d9cee1397810cdb1495
Submitter: Jenkins
Branch: stable/pike

commit 943a0adfc778a3fa6c2c1d9cee1397810cdb1495
Author: Bob.Haddleton <email address hidden>
Date: Thu Aug 17 18:47:17 2017 -0500

    Process input defaults and output transforms for nested AdHoc Actions

    This change steps through all of the nested adhoc actions and processes
    the input defaults and output transformationss in order. The input
    defaults are processed starting with the called class, while the
    transforms are processed starting with the base class definition.

    Closes-Bug: 1711444
    Change-Id: I1873bd13f5424ac5eee8f5750a3fde4e02be1949
    (cherry picked from commit 1cc8b24bfc381f345f9965c8401d3cf48d1ef1b9)

tags: added: in-stable-pike
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/mistral 6.0.0.0b1

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

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/mistral 5.2.0

This issue was fixed in the openstack/mistral 5.2.0 release.

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.