ansible / awx-ee

An Ansible execution environment for AWX project
https://quay.io/ansible/awx-ee
Other
133 stars 156 forks source link

awx-ee testing import request #59

Closed metabsd closed 3 years ago

metabsd commented 3 years ago
bash-4.4$ python
Python 3.8.3 (default, Aug 31 2020, 16:03:14)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.8/site-packages/requests/__init__.py", line 43, in <module>
    import urllib3
  File "/usr/lib/python3.8/site-packages/urllib3/__init__.py", line 7, in <module>
    from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
  File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 11, in <module>
    from .exceptions import (
  File "/usr/lib/python3.8/site-packages/urllib3/exceptions.py", line 2, in <module>
    from .packages.six.moves.http_client import IncompleteRead as httplib_IncompleteRead
ModuleNotFoundError: No module named 'urllib3.packages.six'
metabsd commented 3 years ago
>>> import urllib3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.8/site-packages/urllib3/__init__.py", line 7, in <module>
    from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
  File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 11, in <module>
    from .exceptions import (
  File "/usr/lib/python3.8/site-packages/urllib3/exceptions.py", line 2, in <module>
    from .packages.six.moves.http_client import IncompleteRead as httplib_IncompleteRead
ModuleNotFoundError: No module named 'urllib3.packages.six'
metabsd commented 3 years ago

My bad ... I'm adding pysnow and netaddr to my custom image and I test on this version. Not sure if you have the same problem about the urllib version miss match, So I can close this issue.

metabsd commented 3 years ago

Ok, I test with your container and you don't have the same problem as I have. Sorry again.

dustinmhorvath commented 3 years ago

I think that you and I are trying to accomplish some similar things. Did you ever find a resolution for adding pysnow to the upstream build and getting it to run? I unfortunately rely on pysnow for an inventory source script written in python.

metabsd commented 3 years ago

Hi @dustinmhorvath

I forked the project and add pysnow library by adding servicenow.servicenow collection. I assuming that you need that collection too. I see that the futurs collection servicenow.itsm will be good but for now that collection is not complete and miss couple feature that I need.

For now I fix it manually by opening the container interactively and force a reinstallation of request so after I commit the container and push it.

https://hub.docker.com/repository/docker/metabsd/awx-ee

The latest version of the container is working.

When I have time for this I will figure out what happening and find the reason on request library is corrupted.

I hope that helped you. Have a nice day!

dustinmhorvath commented 3 years ago

For posterity, I found a workaround by adding these bits to the execution-environment.yaml:

---
version: 1
dependencies:
  galaxy: _build/requirements.yml
  system: _build/bindep.txt
+  python: _build/requirements.txt
additional_build_steps:
  append:
    - RUN alternatives --set python /usr/bin/python3
      # Reinstalling these here for some reason. Might be a python bug with these in the normal _build/requirements.txt
+    - RUN pip3 install --upgrade pip urllib3 requests six
    - COPY --from=quay.io/project-receptor/receptor:0.9.7 /usr/bin/receptor /usr/bin/receptor
    - RUN mkdir -p /var/run/receptor
    - ADD run.sh /run.sh
    - CMD /run.sh
    - USER 1000
    - RUN git lfs install

This seems to have fixed the issue for now. My guess is that pysnow/urllib3/six/requests have some issues going on with dependencies, and maybe with python libraries coming from the package manager. This solution is a little brutish, but seems to stomp it all out for now.