Make sure std.javascript raises ActionException if its javascript does

Bug #1471737 reported by Renat Akhmerov
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mistral
Invalid
Medium
Nikolay Makhotkin
Liberty
Invalid
Medium
Nikolay Makhotkin

Bug Description

Make sure std.javascript raises ActionException if its javascript does. Need to test and fix if needed.

Changed in mistral:
milestone: none → liberty-2
assignee: nobody → Nikolay Makhotkin (nmakhotkin)
Revision history for this message
Moshe Elisha (melisha) wrote :

PyV8 throws an exception and an ActionException is thrown:

2015-07-06 11:27:52.355 9549 INFO workflow_trace [-] Action execution 'nova.servers_get' [RUNNING -> ERROR, error = Failed to run action [action_ex_id=e2aa2076-ee2a-465e-b834-e89971d1b5d7, action_cls='<class 'mistral...] (execution_id=e3
9156cc-2f33-4193-bc30-f9b5d13fc1fb)
2015-07-06 11:27:52.364 9571 ERROR mistral.engine.default_executor [-] Failed to run action [action_ex_id=c71c6b0b-1769-4fb6-a4c4-7d92072b3f67, action_cls='<class 'mistral.actions.action_factory.NovaAction'>', attributes='{u'client_metho
d_name': u'servers.get'}', params='{u'server': u'd1433867-5b08-4424-ba4a-9d919bd1f8ff'}']
 NovaAction.servers.get failed: <class 'novaclient.exceptions.NotFound'>: Instance could not be found
2015-07-06 11:27:52.364 9571 TRACE mistral.engine.default_executor Traceback (most recent call last):
2015-07-06 11:27:52.364 9571 TRACE mistral.engine.default_executor File "/usr/lib/python2.7/site-packages/mistral/engine/default_executor.py", line 52, in run_action
2015-07-06 11:27:52.364 9571 TRACE mistral.engine.default_executor result = action.run()
2015-07-06 11:27:52.364 9571 TRACE mistral.engine.default_executor File "/usr/lib/python2.7/site-packages/mistral/actions/openstack/base.py", line 78, in run
2015-07-06 11:27:52.364 9571 TRACE mistral.engine.default_executor (self.__class__.__name__, self.client_method_name, e_str)
2015-07-06 11:27:52.364 9571 TRACE mistral.engine.default_executor ActionException: NovaAction.servers.get failed: <class 'novaclient.exceptions.NotFound'>: Instance could not be found
2015-07-06 11:27:52.364 9571 TRACE mistral.engine.default_executor

This is the workflow:

---
version: '2.0'

test_exception:
  type: direct
  tasks:
    js_task:
      action: std.javascript
      input:
        context: <% $ %>
        script: throw "JavaScript custom exception"
      on-success:
        - success
      on-error:
        - error

    error:
      action: std.noop

    success:
      action: std.noop

This is the task-list:

+--------------------------------------+---------+----------------+--------------------------------------+---------+
| ID | Name | Workflow name | Execution ID | State |
+--------------------------------------+---------+----------------+--------------------------------------+---------+
| 223aec2b-eff8-49dd-a149-8b3b20414cd8 | js_task | test_exception | 77d7dfb2-92c5-4b65-8477-f22c14b390a4 | ERROR |
| 6d89e1bc-5fe1-4920-8044-beb4b14fc085 | error | test_exception | 77d7dfb2-92c5-4b65-8477-f22c14b390a4 | SUCCESS |
+--------------------------------------+---------+----------------+--------------------------------------+---------+

Revision history for this message
Moshe Elisha (melisha) wrote :

Sorry. This is the correct stacktrace:

2015-07-06 15:48:10.294 9571 TRACE mistral.engine.default_executor Traceback (most recent call last):
2015-07-06 15:48:10.294 9571 TRACE mistral.engine.default_executor File "/usr/lib/python2.7/site-packages/mistral/engine/default_executor.py", line 52, in run_action
2015-07-06 15:48:10.294 9571 TRACE mistral.engine.default_executor result = action.run()
2015-07-06 15:48:10.294 9571 TRACE mistral.engine.default_executor File "/usr/lib/python2.7/site-packages/mistral/actions/std_actions.py", line 383, in run
2015-07-06 15:48:10.294 9571 TRACE mistral.engine.default_executor raise exc.ActionException("JavaScriptAction failed: %s" % str(e))
2015-07-06 15:48:10.294 9571 TRACE mistral.engine.default_executor ActionException: JavaScriptAction failed: JSError: JavaScript custom exception ( @ 2 : 16 ) -> throw "JavaScript custom exception"
2015-07-06 15:48:10.294 9571 TRACE mistral.engine.default_executor

Revision history for this message
Nikolay Makhotkin (nmakhotkin) wrote :

Ok, I just reverified this.

1. std.javascript indeed raises ActionException if we throw it via script itself
2. ActionException leads to ERROR in action, then it leads to ERROR in with-items and fail the whole workflow execution.

See example:

Have the following workflow:

---
version: "2.0"

name: test_js

workflows:
  js_test:
    type: direct

    tasks:
      task1:
        with-items: num in <% list(range(1, 10)) %>
        action: std.javascript
        input:
          script: |
            if ($.num % 2 == 0) {
              throw 'JS exception'
            }
            else {
              return $.num
            }
          context: <% $ %>

And here is the result:

workflow-execution:

| ed0e3837-9db6-4ca4-a841-676d11cc1e1a | test_js.js_test | | ERROR | Failure caused by error i... | 2015-07-06 15:27:56 | 2015-07-06 15:27:57 |

task-execution:

| e7f37881-c6dc-49d9-b5a2-940dc2aa1dc6 | task1 | test_js.js_test | ed0e3837-9db6-4ca4-a841-676d11cc1e1a | ERROR |

action-execution-list:

+--------------------------------------+----------------+-----------------+-----------+---------+------------+-------------+
| ID | Name | Workflow name | Task name | State | State info | Is accepted |
+--------------------------------------+----------------+-----------------+-----------+---------+------------+-------------+
| 1a7bfcd1-7dc6-45e9-a502-a3436587349f | std.javascript | test_js.js_test | task1 | ERROR | None | False |
| 7ef22829-31a5-4dd0-91db-99547e629485 | std.javascript | test_js.js_test | task1 | ERROR | None | False |
| 97058563-6123-400b-a45c-94dc24a6a80e | std.javascript | test_js.js_test | task1 | SUCCESS | None | True |
| ac43d554-b669-4c12-adf8-11179594d25a | std.javascript | test_js.js_test | task1 | SUCCESS | None | True |
| ba79725b-933f-41f2-ad9d-df8069dc9c9e | std.javascript | test_js.js_test | task1 | SUCCESS | None | True |
| d4f83301-0adf-4e22-86db-3b10763b4869 | std.javascript | test_js.js_test | task1 | SUCCESS | None | True |
| d8c9fb1e-3d94-400e-9012-6115b80a81dc | std.javascript | test_js.js_test | task1 | ERROR | None | False |
| e69a52a6-f93b-48c4-ab60-3a9e96340459 | std.javascript | test_js.js_test | task1 | SUCCESS | None | True |
| efbc680c-7fbf-47dd-a63b-8c89d672d430 | std.javascript | test_js.js_test | task1 | ERROR | None | False |
+--------------------------------------+----------------+-----------------+-----------+---------+------------+-------------+

Changed in mistral:
milestone: 1.0.0 → none
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.