Skip to content

Conversation

@blag
Copy link
Contributor

@blag blag commented Oct 29, 2020

The end-to-end tests are failing on Ubuntu 16 because they don't have Python 3.6 available, which is blocking my PR #5064:

not ok 36 packs.setup_virtualenv with python3 flag works
# (in test file cli/test_pack_python3.bats, line 88)
#   `RESULT=$(st2 run examples.python_runner_print_python_version -j)' failed with status 127
not ok 37 python3 imports work correctly
# (from function `assert_success' in file cli/../test_helpers/bats-assert/src/assert.bash, line 114,
#  in test file cli/test_pack_python3.bats, line 117)
#   `assert_success' failed with status 127
# 
# -- command failed --
# status : 1
# output (19 lines):
#   
#   {
#       \"action\": {
#           \"ref\": \"python3_test.test_stdlib_import\"
#       }, 
#       \"context\": {
#           \"user\": \"st2admin\"
#       }, 
#       \"end_timestamp\": \"2020-10-29T00:47:52.928925Z\", 
#       \"id\": \"5f9a1138f016f26a2a042272\", 
#       \"result\": {
#           \"exit_code\": 1, 
#           \"result\": \"None\", 
#           \"stderr\": \"Traceback (most recent call last):\
  File \\\"/opt/stackstorm/st2/lib/python2.7/site-packages/netaddr/compat.py\\\", line 91, in <module>\
    from importlib import resources as _importlib_resources\
ImportError: cannot import name 'resources'\
\
During handling of the above exception, another exception occurred:\
\
Traceback (most recent call last):\
  File \\\"/opt/stackstorm/st2/local/lib/python2.7/site-packages/python_runner/python_action_wrapper.py\\\", line 53, in <module>\
    from st2common import log as logging\
  File \\\"/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/log.py\\\", line 32, in <module>\
    from st2common.logging.handlers import FormatNamedFileHandler\
  File \\\"/opt/stackstorm/st2/lib/python2.7/site-packages/st2common/logging/handlers.py\\\", line 22, in <module>\
    from oslo_config import cfg\
  File \\\"/opt/stackstorm/st2/lib/python2.7/site-packages/oslo_config/cfg.py\\\", line 336, in <module>\
    from oslo_config import types\
  File \\\"/opt/stackstorm/st2/lib/python2.7/site-packages/oslo_config/types.py\\\", line 21, in <module>\
    import netaddr\
  File \\\"/opt/stackstorm/st2/lib/python2.7/site-packages/netaddr/__init__.py\\\", line 18, in <module>\
    from netaddr.core import (AddrConversionError, AddrFormatError,\
  File \\\"/opt/stackstorm/st2/lib/python2.7/site-packages/netaddr/core.py\\\", line 11, in <module>\
    from netaddr.compat import _callable, _iter_dict_keys\
  File \\\"/opt/stackstorm/st2/lib/python2.7/site-packages/netaddr/compat.py\\\", line 93, in <module>\
    import importlib_resources as _importlib_resources\
  File \\\"/opt/stackstorm/st2/lib/python2.7/site-packages/importlib_resources/__init__.py\\\", line 31, in <module>\
    from importlib_resources._py3 import (\
  File \\\"/opt/stackstorm/st2/lib/python2.7/site-packages/importlib_resources/_py3.py\\\", line 20, in <module>\
    Resource = Union[str, os.PathLike]\
AttributeError: module 'os' has no attribute 'PathLike'\
\", 
#           \"stdout\": \"\"
#       }, 
#       \"start_timestamp\": \"2020-10-29T00:47:52.507461Z\", 
#       \"status\": \"failed\"
#   }
# --
# 

This PR tweaks the st2_pkg_e2e_test workflow to check for Ubuntu 16 and if detected, installs Python 3.6 from the deadsnakes PPA and configures StackStorm to use it utilizing the patch utility and Bash heredocs.

@blag blag added the bug label Oct 29, 2020
@blag blag force-pushed the handle-python36-on-ubuntu16 branch from 0674b36 to a27c9d9 Compare October 29, 2020 10:35
@blag blag force-pushed the handle-python36-on-ubuntu16 branch from a27c9d9 to 8aacaee Compare October 29, 2020 10:46
@blag
Copy link
Contributor Author

blag commented Oct 29, 2020

This code does not change what StackStorm itself runs under, and yes, on Ubuntu 16 and RHEL 7, StackStorm itself runs with Python 2.7.

What this change does is tweak what version of Python StackStorm uses when installing packs with the --python3 flag (st2 pack install --python3 mypack). Previously it was using the system's Python 3 version, which is Python 3.5 for Ubuntu 16. Unfortunately, Python 3.5 does not implement os.PathLike, so we need to tell StackStorm to use Python 3.6+ when installing Python 3 packs.

One point to consider is that this should work just fine for the current unstable builds, but we might want to consider continuing to use Python 3.5 for the stable builds on Ubuntu 16 and any 3.3.x releases.

Copy link
Member

@arm4b arm4b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per discussion we agreed to provide python3.6 PPA via curl|bash installer based on user's y/n input. See: StackStorm/st2-packages#681 and we can adjust this PR afterwards.

That would be better as adding repo beforehand defeats the purpose of end-to-end tests.

@blag blag force-pushed the handle-python36-on-ubuntu16 branch 4 times, most recently from 5720dd4 to 7499b7f Compare December 14, 2020 21:12
@blag blag force-pushed the handle-python36-on-ubuntu16 branch from 7499b7f to 0dfc064 Compare December 14, 2020 23:07
@blag blag force-pushed the handle-python36-on-ubuntu16 branch from 2e2b7dd to 7c54683 Compare December 15, 2020 20:40
@blag
Copy link
Contributor Author

blag commented Dec 15, 2020

I reworked this to use echo 'y' | when running the bootstrap script.

@blag blag requested a review from arm4b December 15, 2020 20:41
@amanda11
Copy link
Contributor

Excellent - LGTM - should fix the E2Es.

@blag
Copy link
Contributor Author

blag commented Dec 15, 2020

Once our current E2E builds finish up I'll install this branch on st2cicd and try it out. I won't merge this until it's at least tested.

# If pipe_into_bootstrap_script is not empty, return it + " | "
# If pipe_into_bootstrap_script is empty, return an empty string
cmd: >-
<% switch(ctx().pipe_into_bootstrap_script => concat(ctx().pipe_into_bootstrap_script, " | "), true => "") %>
Copy link
Member

@arm4b arm4b Dec 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should work in this particular case.

However I provided --u16-add-insecure-py3-ppa flag as identified more bash corner cases with the interactive mode under different environments. StackStorm/st2-packages#682. It might be more clear to rely on that new flag.

Comment on lines 139 to 141
bash /tmp/st2_bootstrap.sh
--<% ctx().pkg_env %>
--<% ctx().release %>
Copy link
Member

@arm4b arm4b Dec 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to pass that U16 flag to script directly without extra workflow logic as our installer is catch-all and won't fail in case of non-existent CLI param provided.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even better!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As StackStorm/st2-packages#682 is now merged, you can add --u16-add-insecure-py3-ppa

@blag blag closed this in #197 Mar 2, 2021
@blag blag deleted the handle-python36-on-ubuntu16 branch March 2, 2021 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants