Remove nonexistent actions from database when upgrading/downgrading a pack
SUMMARY
Actions are not removed when upgrading/downgrading packs.
ISSUE TYPE
- Bug Report
STACKSTORM VERSION
Paste the output of st2 --version:
st2 3.0dev (7524cc8), on Python 2.7.12
(on st2cicd037)
OS / ENVIRONMENT / INSTALL METHOD
Ubuntu 16.04.5 LTS
Installed via st2cicd.build-controller
STEPS TO REPRODUCE
- Install most recent version of AWS pack.
- Note all of the actions, specifically the
aws.ec2_describe_instancesaction exists and is runnable from theActionstab in the web UI and from a workflow task. - Install AWS pack from the
v0.10.0orv0.10.1tags usingst2 pack install ...WITHOUT runningst2 pack remove aws. - Note all of the actions, specifically the
aws.ec2_describe_instancesaction still exists, and is even runnable from theActionstab in the web UI. - Create a workflow that calls
aws.ec2_describe_instancesfrom a task. Note the incomprehensible error.
Action metadata:
---
name: remote_windows
runner_type: orquesta
description: ...
enabled: true
entry_point: workflows/remote_windows.yaml
parameters:
instance_id:
type: string
description: EC2 instance ID
Workflow:
---
version: '1.0'
description: Remote into a Windows EC2 instance
input:
- instance_id
tasks:
get_instance:
action: aws.ec2_describe_instances
input:
InstanceIds: <% ctx().instance_id %>
EXPECTED RESULTS
A better error message is desirable, but it is probably easier to simply remove all actions that exist in the database but not in an action metadata file when running st2 pack install ....
ACTUAL RESULTS
An incomprehensible error:
{
"output": null,
"errors": [
{
"message": "SyntaxError: unexpected EOF while parsing (<unknown>, line 0)",
"type": "error",
"task_id": "get_instance"
}
]
}
I had this same error when a workflow parameter was incorrectly defined as array type when it should have been string. This leads to St2 processing the string as an object literal. The Python exception is logged:
File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/services/workflows.py", line 680, in request_task_execution
raise e
File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/services/workflows.py", line 663, in request_task_execution
wf_ex_db, task_ex_db, st2_ctx, ac_ex_req, delay=ac_ex_delay
File "/opt/stackstorm/st2/lib/python3.6/site-packages/retrying.py", line 49, in wrapped_f
return Retrying(*dargs, **dkw).call(f, *args, **kw)
File "/opt/stackstorm/st2/lib/python3.6/site-packages/retrying.py", line 206, in call
return attempt.get(self._wrap_exception)
File "/opt/stackstorm/st2/lib/python3.6/site-packages/retrying.py", line 247, in get
six.reraise(self.value[0], self.value[1], self.value[2])
File "/opt/stackstorm/st2/lib/python3.6/site-packages/six.py", line 696, in reraise
raise value
File "/opt/stackstorm/st2/lib/python3.6/site-packages/retrying.py", line 200, in call
attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
File "/opt/stackstorm/st2/lib/python3.6/site-packages/retrying.py", line 49, in wrapped_f
return Retrying(*dargs, **dkw).call(f, *args, **kw)
File "/opt/stackstorm/st2/lib/python3.6/site-packages/retrying.py", line 206, in call
return attempt.get(self._wrap_exception)
File "/opt/stackstorm/st2/lib/python3.6/site-packages/retrying.py", line 247, in get
six.reraise(self.value[0], self.value[1], self.value[2])
File "/opt/stackstorm/st2/lib/python3.6/site-packages/six.py", line 696, in reraise
raise value
File "/opt/stackstorm/st2/lib/python3.6/site-packages/retrying.py", line 200, in call
attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/services/workflows.py", line 767, in request_action_execution
ac_ex_ctx,
File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/util/param.py", line 343, in render_live_params
params, context, [action_parameters, runner_parameters]
File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/util/param.py", line 266, in _cast_params_from
result[name] = _cast(context[name], param_schema)
File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/util/param.py", line 87, in _cast
return cast(v)
File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/util/casts.py", line 40, in _cast_object
return ast.literal_eval(x)
File "/usr/lib/python3.6/ast.py", line 48, in literal_eval
node_or_string = parse(node_or_string, mode='eval')
File "/usr/lib/python3.6/ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 1
host.example.com.
^
SyntaxError: unexpected EOF while parsing
However the workflow execution produces the below output which is misleading/unhelpful to diagnose the cause of the error because it doesn't indicate the parameter name or value as the source of the error:
result:
errors:
- message: Execution failed. See result for details.
result:
errors:
- message: 'SyntaxError: unexpected EOF while parsing (<unknown>, line 1)'
route: 1
task_id: process_records
type: error
output: null
task_id: process_zones
type: error