Sensor ref pulling from pack directory name instead of pack ref?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 6.5k
- Forks
- 787
- PR merge metrics
- No merged PRs in 30d
Description
I was messing around with some of my test packs and noticed some odd behavior on 2.3.2. For developing packs, I usually add them to my st2vagrant rsync configuration. However, this time I accidentally forgot to remove the stackstorm- prefix, and the full name carried into /opt/stackstorm/packs:
vagrant@st2vagrant:/opt/stackstorm/packs$ ll
total 44
drwxrwxr-x 11 root st2packs 4096 Aug 17 06:25 ./
drwxr-xr-x 11 root root 4096 Aug 16 05:56 ../
drwxrwxr-x 5 root st2packs 4096 Aug 16 05:54 chatops/
drwxrwxr-x 5 root st2packs 4096 Aug 16 05:54 core/
drwxrwxr-x 5 root st2packs 4096 Aug 16 05:54 default/
drwxrwxr-x 4 root st2packs 4096 Aug 16 05:54 linux/
drwxr-xr-x 8 vagrant vagrant 4096 May 13 22:19 napalm/
drwxrwxr-x 5 root st2packs 4096 Aug 16 05:54 packs/
drwxrwxr-x 6 root st2packs 4096 Aug 16 05:54 st2/
drwxr-xr-x 3 vagrant vagrant 4096 Aug 17 20:29 stackstorm-testpack/
That's okay, at least the pack API uses the ref inside pack.yaml, so we're okay so far:
vagrant@st2vagrant:/opt/stackstorm/packs$ cat stackstorm-testpack/pack.yaml
---
name: testpack
description: A collection of tests and experiments
version: 0.1.0
author: mierdin
email: info@stackstorm.com
vagrant@st2vagrant:/opt/stackstorm/packs$ st2 pack list
+----------+----------+------------------------------------------------+---------+-----------------------+
| ref | name | description | version | author |
+----------+----------+------------------------------------------------+---------+-----------------------+
| chatops | chatops | ChatOps integration pack | 0.3.0 | Kirill Enykeev |
| core | core | st2 content pack containing basic actions. | 0.3.1 | st2-dev |
| default | default | Pack where all the resources which are created | 0.1.0 | st2-dev |
| | | using the API and don't have a pack specified | | |
| | | get saved. | | |
| linux | linux | Generic linux actions | 0.1.0 | st2-dev |
| napalm | napalm | A StackStorm pack for working with network | 0.2.3 | mierdin, Rob Woodward |
| | | devices using the NAPALM library | | |
| packs | packs | core st2 content pack containing pack | 0.2.0 | st2-dev |
| | | management functionality. | | |
| st2 | st2 | StackStorm pack management | 0.3.0 | StackStorm, Inc. |
| testpack | testpack | A collection of tests and experiments | 0.1.0 | mierdin |
+----------+----------+------------------------------------------------+---------+-----------------------+
However, when looking at Sensors, I noticed the ref for the Sensor in this pack contains the stackstorm- prefix:
vagrant@st2vagrant:/opt/stackstorm/packs$ st2 sensor list
+------------------------------------+------------------+------------------------------------------------------------+---------+
| ref | pack | description | enabled |
+------------------------------------+------------------+------------------------------------------------------------+---------+
| stackstorm-testpack.TestSensor | testpack | Test sensor that emits triggers. | False |
| linux.FileWatchSensor | linux | Sensor which monitors files for new lines | False |
| napalm.NapalmLLDPSensor | napalm | Sensor that uses NAPALM to retrieve LLDP information from | True |
| | | network devices | |
+------------------------------------+------------------+------------------------------------------------------------+---------+
The only place this prefix is given is in the directory name, which begs the question, do we retrieve Sensor refs from the directory name instead of the pack ref inside pack.yaml? I haven't tried looking at where else this is impacted, but this might be worth looking into.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the behavior using a pack directory named stackstorm-testpack and the pack.yaml shown in the report. Trace how sensor refs are assembled compared with pack metadata, then verify that st2 sensor list reports the pack ref from pack.yaml rather than the directory name.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100