New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] salt-ssh from newer Python (3.9) to 3.6.x host fails #61419
Comments
same issue |
Also same issue, would love to see a workaround for this even if a real fix won't come for a good while |
The issue seems to come from these lines: Lines 429 to 435 in 38341cb
Given that a 3.7+ master is not going to have the backport (Or prefer it if its installed), this means that an incompatible version of contextvars gets packaged before being sent to the 3.6 target. I was able to solve this in our system by commenting these lines, then using the pre-flight script to install the contextvars backport. Not sure right now how to best handle this without using pre-flight |
Same here, commenting these lines on my salt-ssh client side (running with python 3.10), and installing contextvars using pip on my python3.6 server was successfull. Python 3.10 contextvars.py is packaged in the salt-ssh thin but this contextvars.py version is not compatible if servers are running python 3.6/3.7 anyway. |
This is already fixed, but is a bit counter-intuitive: you need to install An execution returning the already known error:
Then, install
In the
And it's there exactly to make
Take care that the |
Thanks for the detailed walkthrough @piterpunk. I've followed your instructions and can confirms that on my setup (Archlinux source salt-ssh on a Python 3.9 virtualenv, Rockylinux 8 target using the system Python 3.6), installing This is particularly confusing considering contextvars==2.4 is already installed on the target host, as part of a regular salt-3004 on python3.6 install. salt --versions-reportSalt Version:
Salt: 3004.2
Dependency Versions:
cffi: 1.15.0
cherrypy: Not Installed
dateutil: Not Installed
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 3.1.2
libgit2: 1.1.0
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.0.4
msgpack-pure: Not Installed
mysql-python: Not Installed
pycparser: 2.21
pycrypto: Not Installed
pycryptodome: 3.15.0
pygit2: 1.5.0
Python: 3.9.12 (main, May 15 2022, 19:24:24)
python-gnupg: Not Installed
PyYAML: 6.0
PyZMQ: 21.0.2
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.3
System Versions:
dist: arch
locale: utf-8
machine: x86_64
release: 5.18.6-arch1-1
system: Linux
version: Arch Linux salt-call --versions-report (on target host) Salt Version:
Salt: 3004.2
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: 2.6.1
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
Jinja2: 2.10.1
libgit2: Not Installed
M2Crypto: 0.35.2
Mako: Not Installed
msgpack: 0.6.2
msgpack-pure: Not Installed
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: Not Installed
pycryptodome: Not Installed
pygit2: Not Installed
Python: 3.6.8 (default, Apr 12 2022, 06:55:39)
python-gnupg: Not Installed
PyYAML: 3.12
PyZMQ: 19.0.0
smmap: Not Installed
timelib: Not Installed
Tornado: 4.5.3
ZMQ: 4.3.4
System Versions:
dist: rocky 8.6 Green Obsidian
locale: UTF-8
machine: x86_64
release: 4.18.0-372.9.1.el8.x86_64
system: Linux
version: Rocky Linux 8.6 Green Obsidian EDIT: Turns out I've stumbled upon this issue already back in January and I found another workaround on a duplicate issue, #59942 (comment) that's related to an issue with To whom it may concern, if Piter's instructions aren't sufficient because your issue is caused by |
I just installed salt-ssh on a centos 7 via rpm repo. When connecting to another centos 7 machine, after installing python3.x86_64 and python36-distro.noarch (because got another error as well), got this error: salt-ssh -v -i '*' test.ping
|
Description
salt-ssh on a Python 3.9 host and a Python 3.6.15 target fails with
ModuleNotFoundError: No module named '_contextvars'
error:Setup
My setup on the host is a Nix environment with Salt 3004 and a target machine with openSUSE and Python 3.9.15 on ARM, but from what I see in the code, it should happen on a Python > 3.7 host / Python 3.6 target.
Steps to Reproduce the behavior
After running
salt-ssh rpi01 grains.items
, it will fail:I believe the reason could be (I could be wrong):
/var/tmp/.root_05dd7c_salt/pyall/salt/loader/context.py
does:The fallback import should end importing contextvars backport. but because
sys.path
includes/var/tmp/.root_05dd7c_salt/py3/contextvars.py
first, which is a copy of the 3.9 stdlib, which also depends on_contextvars
!! native module:which brings Python 3.6 back into importing something that is not in Python 3.6, even if the backport package is installed on the machine.
So there are a few things I can't make sense of:
The contextvars backport states:
So I assume just importing just
context
insalt/loader/context.py
should attempt to load the 3.7 module, or fallback to the backport.contextvars
without depending on_contextvars
, so if we are on a newer Python, this module is already included, and if we are on < 3.6, the 3.7 module can't be used. What is the point of copying it?Fixes and workarounds
Just deleting
rm /var/tmp/.root_05dd7c_salt/py3/contextvars.py
makes things work, as Python 3.6 would then use the installed contextvars backport.I tried to use python 3.9 on the target machine. It would still use the "wrong"
py3
dir module, but it would work as_contextvars
is available. salt-ssh does not allow me to select /usr/bin/python3.9 as the interpreter to use in the target machine, so it uses /usr/bin/python3.My intuition tells me there is no point in packing contextvars in the thin, unless we are packing the backport package.
Expected behavior
salt-ssh rpi01 grains.items
to worksalt --versions-report
Host:
Target:
The text was updated successfully, but these errors were encountered: