fmnisme / err-stackstorm

a plugin for stackstorm
Apache License 2.0
15 stars 4 forks source link

Setup issues #22

Closed ChrisMcKee closed 6 years ago

ChrisMcKee commented 6 years ago

Ubuntu 16.04 LTS

Having had no luck getting setup I decided to try this again on a clean machine without using virtualenv.

sudo apt-get install python-pip git python3-pip build-essentials cmake libffi-dev sudo pip3 install errbot mkdir errbot && cd errbot && errbot --init pip3 install "errbot[slack]" errbot

I ran the install plugin command and failed with the following output.

Output

[@CHANGE_ME ➡ @errbot] >>> !repos install https://github.com/fmnisme/err-stackstorm.git
[@CHANGE_ME ➡ @errbot] [␍]
Installing https://github.com/fmnisme/err-stackstorm.git...
Collecting st2client>=2.5.0 (from -r /home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/requirements.txt (line 1))
  Downloading st2client-2.5.1-py2-none-any.whl (145kB)
    100% |████████████████████████████████| 153kB 2.2MB/s
Collecting sseclient-py (from -r /home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/requirements.txt (line 2))
  Downloading sseclient_py-1.7-py2.py3-none-any.whl
Collecting jsonpath-rw>=1.3.0 (from st2client>=2.5.0->-r /home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/requirements.txt (line 1))
  Downloading jsonpath-rw-1.4.0.tar.gz
Collecting pyyaml<4.0,>=3.11 (from st2client>=2.5.0->-r /home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/requirements.txt (line 1))
  Downloading PyYAML-3.12.tar.gz (253kB)
    100% |████████████████████████████████| 256kB 1.5MB/s
Collecting six==1.10.0 (from st2client>=2.5.0->-r /home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/requirements.txt (line 1))
  Downloading six-1.10.0-py2.py3-none-any.whl
Collecting python-dateutil (from st2client>=2.5.0->-r /home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/requirements.txt (line 1))
  Downloading python_dateutil-2.6.1-py2.py3-none-any.whl (194kB)
    100% |████████████████████████████████| 194kB 1.6MB/s
Collecting requests[security]<2.15,>=2.14.1 (from st2client>=2.5.0->-r /home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/requirements.txt (line 1))
  Downloading requests-2.14.2-py2.py3-none-any.whl (560kB)
    100% |████████████████████████████████| 563kB 1.5MB/s
Collecting prettytable (from st2client>=2.5.0->-r /home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/requirements.txt (line 1))
  Downloading prettytable-0.7.2.zip
Collecting ply (from jsonpath-rw>=1.3.0->st2client>=2.5.0->-r /home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/requirements.txt (line 1))
  Downloading ply-3.10.tar.gz (150kB)
    100% |████████████████████████████████| 153kB 3.8MB/s
Collecting decorator (from jsonpath-rw>=1.3.0->st2client>=2.5.0->-r /home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/requirements.txt (line 1))
  Downloading decorator-4.2.1-py2.py3-none-any.whl
Collecting idna>=2.0.0; extra == "security" (from requests[security]<2.15,>=2.14.1->st2client>=2.5.0->-r /home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/requirements.txt (line 1))
  Using cached idna-2.6-py2.py3-none-any.whl
Collecting cryptography>=1.3.4; extra == "security" (from requests[security]<2.15,>=2.14.1->st2client>=2.5.0->-r /home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/requirements.txt (line 1))
  Downloading cryptography-2.1.4-cp27-cp27mu-manylinux1_x86_64.whl (2.2MB)
    100% |████████████████████████████████| 2.2MB 419kB/s
Collecting pyOpenSSL>=0.14; extra == "security" (from requests[security]<2.15,>=2.14.1->st2client>=2.5.0->-r /home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/requirements.txt (line 1))
  Downloading pyOpenSSL-17.5.0-py2.py3-none-any.whl (53kB)
    100% |████████████████████████████████| 61kB 1.4MB/s
Collecting cffi>=1.7; platform_python_implementation != "PyPy" (from cryptography>=1.3.4; extra == "security"->requests[security]<2.15,>=2.14.1->st2client>=2.5.0->-r /home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/requirements.txt (line 1))
  Downloading cffi-1.11.4-cp27-cp27mu-manylinux1_x86_64.whl (406kB)
    100% |████████████████████████████████| 409kB 1.6MB/s
Collecting enum34; python_version < "3" (from cryptography>=1.3.4; extra == "security"->requests[security]<2.15,>=2.14.1->st2client>=2.5.0->-r /home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/requirements.txt (line 1))
  Downloading enum34-1.1.6-py2-none-any.whl
Collecting asn1crypto>=0.21.0 (from cryptography>=1.3.4; extra == "security"->requests[security]<2.15,>=2.14.1->st2client>=2.5.0->-r /home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/requirements.txt (line 1))
  Using cached asn1crypto-0.24.0-py2.py3-none-any.whl
Collecting ipaddress; python_version < "3" (from cryptography>=1.3.4; extra == "security"->requests[security]<2.15,>=2.14.1->st2client>=2.5.0->-r /home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/requirements.txt (line 1))
  Downloading ipaddress-1.0.19.tar.gz
Collecting pycparser (from cffi>=1.7; platform_python_implementation != "PyPy"->cryptography>=1.3.4; extra == "security"->requests[security]<2.15,>=2.14.1->st2client>=2.5.0->-r /home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/requirements.txt (line 1))
Building wheels for collected packages: jsonpath-rw, pyyaml, prettytable, ply, ipaddress
  Running setup.py bdist_wheel for jsonpath-rw ... done
  Stored in directory: /home/ubuntu/.cache/pip/wheels/ff/80/3d/6d630248dd938306a8691b9658ee91e07fb794076d714f8ce8
  Running setup.py bdist_wheel for pyyaml ... done
  Stored in directory: /home/ubuntu/.cache/pip/wheels/2c/f7/79/13f3a12cd723892437c0cfbde1230ab4d82947ff7b3839a4fc
  Running setup.py bdist_wheel for prettytable ... done
  Stored in directory: /home/ubuntu/.cache/pip/wheels/b6/90/7b/1c22b89217d0eba6d5f406e562365ebee804f0d4595b2bdbcd
  Running setup.py bdist_wheel for ply ... done
  Stored in directory: /home/ubuntu/.cache/pip/wheels/ad/dd/ad/8ce1991a7b380dfe23d6cc81a4de5c2775bc728b5a0a7721aa
  Running setup.py bdist_wheel for ipaddress ... done
  Stored in directory: /home/ubuntu/.cache/pip/wheels/d7/6b/69/666188e8101897abb2e115d408d139a372bdf6bfa7abb5aef5
Successfully built jsonpath-rw pyyaml prettytable ply ipaddress
Installing collected packages: ply, decorator, six, jsonpath-rw, pyyaml, python-dateutil, idna, pycparser, cffi, enum34, asn1crypto, ipaddress, cryptography, pyOpenSSL, requests, prettytable, st2client, sseclient-py
Successfully installed asn1crypto cffi cryptography decorator enum34 idna ipaddress jsonpath-rw ply prettytable pyOpenSSL pycparser python-dateutil pyyaml-3.11 requests six-1.10.0 sseclient-py st2client
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Some plugins are generating errors:
  File "/home/ubuntu/.local/lib/python3.5/site-packages/yapsy/PluginManager.py", line 485, in loadPlugins
    candidate_module = imp.load_module(plugin_module_name,None,candidate_filepath,("py","r",imp.PKG_DIRECTORY))
  File "/usr/lib/python3.5/imp.py", line 244, in load_module
    return load_package(name, filename)
  File "/usr/lib/python3.5/imp.py", line 216, in load_package
    return _load(spec)
  File "<frozen importlib._bootstrap>", line 693, in _load
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/./init.py", line 2, in <module>
    from st2 import St2
  File "/home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/st2.py", line 7, in <module>
    from lib.st2pluginapi import St2PluginAPI
  File "/home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/lib/st2pluginapi.py", line 7, in <module>
    import sseclient
Removing /home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm as it did not load correctly.
Plugins reloaded.

From Log file

2018-01-14 08:59:20,580 DEBUG    errbot.core               *** text = !repos install https://github.com/fmnisme/err-stackstorm.git

2018-01-14 08:59:20,580 DEBUG    errbot.plugins.ACLs       Check repos_install for ACLs.
2018-01-14 08:59:20,580 INFO     errbot.plugins.ACLs       Matching ACL {} against username @CHANGE_ME for command Plugins:repos_install
2018-01-14 08:59:20,580 INFO     errbot.plugins.ACLs       Check if repos_install is admin only command.
2018-01-14 08:59:20,581 INFO     errbot.core               Processing command 'repos_install' with parameters 'https://github.com/fmnisme/err-stackstorm.git' from @CHANGE_ME
2018-01-14 08:59:20,597 DEBUG    errbot.flow               Test if the command repos_install is a trigger for an inflight flow ...
2018-01-14 08:59:20,597 DEBUG    errbot.flow               None matched.
2018-01-14 08:59:21,822 DEBUG    errbot.plugin_manager     All plugin roots:
2018-01-14 08:59:21,822 DEBUG    errbot.plugin_manager     -> /home/ubuntu/.local/lib/python3.5/site-packages/errbot/core_plugins
2018-01-14 08:59:21,822 DEBUG    errbot.plugin_manager     -> /home/ubuntu/errbot/plugins/err-example
2018-01-14 08:59:21,823 DEBUG    errbot.plugin_manager     -> /home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm
2018-01-14 08:59:21,823 DEBUG    errbot.plugin_manager     Add /home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm to sys.path
2018-01-14 08:59:21,823 DEBUG    errbot.plugin_manager     /home/ubuntu/.local/lib/python3.5/site-packages/errbot/core_plugins has no requirements.txt file
2018-01-14 08:59:21,823 DEBUG    errbot.plugin_manager     /home/ubuntu/errbot/plugins/err-example has no requirements.txt file
2018-01-14 08:59:21,823 INFO     errbot.plugin_manager     Installing packages from '/home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/requirements.txt'.
2018-01-14 08:59:29,849 INFO     errbot                    webhooks:  Flag to bind /echo to                           echo
2018-01-14 08:59:29,869 ERROR    yapsy                     Unable to import plugin: /home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/.
Traceback (most recent call last):
  File "/home/ubuntu/.local/lib/python3.5/site-packages/yapsy/PluginManager.py", line 485, in loadPlugins
    candidate_module = imp.load_module(plugin_module_name,None,candidate_filepath,("py","r",imp.PKG_DIRECTORY))
  File "/usr/lib/python3.5/imp.py", line 244, in load_module
    return load_package(name, filename)
  File "/usr/lib/python3.5/imp.py", line 216, in load_package
    return _load(spec)
  File "<frozen importlib._bootstrap>", line 693, in _load
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/./__init__.py", line 2, in <module>
    from st2 import St2
  File "/home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/st2.py", line 7, in <module>
    from lib.st2pluginapi import St2PluginAPI
  File "/home/ubuntu/errbot/data/plugins/fmnisme/err-stackstorm/lib/st2pluginapi.py", line 7, in <module>
    import sseclient
ImportError: No module named 'sseclient'
nzlosh commented 6 years ago

Hi @ChrisMcKee,

Did you have a StackStorm instance already setup and running and the appropriate plugin configuration included in config.py when you attempted to install the plugin?

In the effort to debug what might be causing the plugin to fail, would you mind installing the plugin manually rather than through the bot command?

Activate the virtualenv (if you're setup is using one) $ activate ~/errbot/bin/activate Change to the plugin directory (make it if it doesn't exist) $ cd ~/errbot/data/plugin/fmnisme Clone the repo. $ git clone https://github.com/fmnisme/err-stackstorm.git Install plugin requirements $ cd err-stackstorm; pip install -r requirements.txt Restart errbot $ cd ~/errbot; errbot

ChrisMcKee commented 6 years ago

Thanks, I'll give that a go! I'd dug into various other GitHub issues and tried manually installing various packages so I'll salt-the-earth

nzlosh commented 6 years ago

Great, let me know how you get on with that. If it works (or at least gives a useful back trace) then I'll see how best to handle this case, either document it or find a way for the error message to be more meaningful when the installation fails.

ChrisMcKee commented 6 years ago

Thanks; that appeared to work bar a few doc issues. In st2,py the default configs https://github.com/fmnisme/err-stackstorm/blob/master/st2.py#L30-L35 vs the config causes bad routing to the api.

Computer says nooo. See logs for details:
404 Client Error: Not Found for url: https://192.168.72.128/api/v1/v1/actionalias/help

I can see my requests getting to StackStorm now from errbot but its a bit of a blackhole at present (says it'll perform the command, never feeds back the result). Closer though.

Not sure why it wouldn't install from the bot then; but it seems ok direct.

I did have to add in

import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

as the logs were just streaming noise with cert verification turned off.

nzlosh commented 6 years ago

I suspect the actual exception being cause during !repo install ... isn't getting raised all the way to the top calling function, so we were just seeing a generalised message ImportError: No module named 'sseclient'. I'll test out a few ideas to improve the installation process, thanks for reporting it.

The url looks like it's got 1 too many v1s. Did you have a look at the troubleshooting section of the plugin docs? Would you be able to join the StackStorm Slack community to discuss your setup directly? http://stackstorm.com/community-signup

ChrisMcKee commented 6 years ago

I copied the paths from the st2.py file to correct the api paths (hence it sorta working now) I'll re-run it all again tomorrow; I discovered an annoying issue with VMWare/Ubuntu wiping state when my laptops in sleep so I've been stuck in a loop of starting from scratch 😁

Thanks for the help and the link; I'll post any question in there. 👍