Open LindsayHill opened 5 years ago
Did a bit of investigation.
st2common/st2common/util/pack_management.py's download_pack will: a) throw an exception if we can't find pack in local repo (https://github.com/StackStorm/st2/blob/master/st2common/st2common/util/pack_management.py#L144-L146) b) return a tuple indicating failed to find and remote (https://github.com/StackStorm/st2/blob/master/st2common/st2common/util/pack_management.py#L109-L112) c) return a tuple indicated ok if successful (https://github.com/StackStorm/st2/blob/master/st2common/st2common/util/pack_management.py#L174)
Then in contrib/packs/actions/pack_mgmt/download.py we: a) raise an error if when we go through the tuple we don't find at least one success.(https://github.com/StackStorm/st2/blob/master/contrib/packs/actions/pack_mgmt/download.py#L100-L112 b) if at least one succeeded then the sanitized_result does NOT include the True/False for that pack to indicate if it were successful or not. Therefore we'd need to change the API result to include the true/false if we want to download all remotes that we can but still indicate what failed.
So I'm just wondering if the expected results for this situation if one pack succeeds, and one fails should be either:
I would have thought it might be better to be consistent and fail at the download if one of the packs referenced doesn't exist, but do not know if there is a historical reason or other consequences why download fail of a remote is different to not finding a local directory.
I just verified that this issue still persists on st2 3.5.0
There is a slight difference in the output depending on the position of the non-existing pack.
non-existing pack as the last argument:
root@st2-launchdev-u20:~# st2 pack install netbox foorbar
[ succeeded ] init_task
[ succeeded ] download_pack
[ succeeded ] make_a_prerun
[ succeeded ] get_pack_dependencies
[ succeeded ] check_dependency_and_conflict_list
[ succeeded ] install_pack_requirements
[ succeeded ] get_pack_warnings
[ succeeded ] register_pack
+-------------+--------------------------------+ | Property | Value | +-------------+--------------------------------+ | ref | netbox | | name | netbox | | description | NetBox DCIM | | version | 2.0.0 | | author | John Anderson, Jefferson White | +-------------+--------------------------------+
2. if there is any existing pack after the non-existing one:
root@st2-launchdev-u20:~# st2 pack install git foorbar netbox
For the "git, foorbar, netbox" packs, the following content will be registered:
actions | 301 rules | 1 sensors | 2 aliases | 0 triggers | 0
Installation may take a while for packs with many items.
[ succeeded ] init_task
[ succeeded ] download_pack
[ succeeded ] make_a_prerun
[ succeeded ] get_pack_dependencies
[ succeeded ] check_dependency_and_conflict_list
[ succeeded ] install_pack_requirements
[ succeeded ] get_pack_warnings
[ running ] register_pack
[ succeeded ] register_pack
+--------+--------+-------------+---------+--------------------------------+ | ref | name | description | version | author | +--------+--------+-------------+---------+--------------------------------+ | git | git | Git SCM | 1.0.0 | StackStorm, Inc. | | netbox | netbox | NetBox DCIM | 2.0.0 | John Anderson, Jefferson White | +--------+--------+-------------+---------+--------------------------------+
So the number of actions, rules, ... to be registered is only shown if the non-existing pack is not the last one in the list.
SUMMARY
If I attempt to install multiple packs using
st2 pack install
, and one of those packs is non-existent, it will silently ignore the failure.ISSUE TYPE
STACKSTORM VERSION
st2 3.0dev (d86747c), on Python 2.7.12
OS / ENVIRONMENT / INSTALL METHOD
one-line install.
STEPS TO REPRODUCE
EXPECTED RESULTS
I expected some error message about "pack foobar not found", similar to if I had just tried
st2 pack install foobar
ACTUAL RESULTS
Install completes 'successfully', since one pack install works.