Issue #5474
closedFor all processes launched by systemd ensure the PATH includes the virtualenv if installed in a virtualenv
Description
Problem¶
The pulp_ansible
plugin uses some dependencies in its task code that use subprocess to call other Python code. Regardless of if that's a good idea or not, a plugin writer expects that a its code is running in a virtualenv if the Installer created one.
The systemd unit definitions do not add the binary areas of the virtualenv to be part of the PATH. Because of this you can import Python code that was installed because the import path is modified, but you couldn't call a binary tool installed by one of those Python packages.
Here's an example of the error in pulp_ansible's functional tests at commit 03ebfbc7cd5da98056c5efb24c091ffdf316ff0a
Traceback (most recent call last):
File "/usr/local/lib/pulp/lib64/python3.7/site-packages/rq/worker.py", line 822, in perform_job
rv = job.perform()
File "/usr/local/lib/pulp/lib64/python3.7/site-packages/rq/job.py", line 605, in perform
self._result = self._execute()
File "/usr/local/lib/pulp/lib64/python3.7/site-packages/rq/job.py", line 611, in _execute
return self.func(*self.args, **self.kwargs)
File "/home/vagrant/devel/pulp_ansible/pulp_ansible/app/tasks/collections.py", line 133, in import_collection
artifact_file, filename=filename, logger=import_logger
File "/usr/local/lib/pulp/lib64/python3.7/site-packages/galaxy_importer/collection.py", line 44, in import_collection
return _import_collection(file, filename, logger)
File "/usr/local/lib/pulp/lib64/python3.7/site-packages/galaxy_importer/collection.py", line 52, in _import_collection
data = CollectionLoader(extract_dir, filename, logger=logger).load()
File "/usr/local/lib/pulp/lib64/python3.7/site-packages/galaxy_importer/collection.py", line 80, in load
self.content_objs = list(self._load_contents())
File "/usr/local/lib/pulp/lib64/python3.7/site-packages/galaxy_importer/collection.py", line 121, in _load_contents
content_obj = loader.load()
File "/usr/local/lib/pulp/lib64/python3.7/site-packages/galaxy_importer/loaders.py", line 157, in load
for line in self._lint_role(self.rel_path):
File "/usr/local/lib/pulp/lib64/python3.7/site-packages/galaxy_importer/loaders.py", line 185, in _lint_role
stdout=PIPE,
File "/usr/lib64/python3.7/subprocess.py", line 756, in __init__
restore_signals, start_new_session)
File "/usr/lib64/python3.7/subprocess.py", line 1499, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ansible-lint': 'ansible-lint'
Solution¶
Check the Installer's systemd scripts to ensure they are manipulating the PATH correctly to include the shell areas of the virutalenv also.
Added by bmbouter over 4 years ago
Added by bmbouter over 4 years ago
Revision 5a161582 | View on GitHub
Add virtualenv /bin/ to systemd PATH
The systemd files did not manipulate the binary, so the Python import
would be inside the virtualenv a call to subprocess
would not.
Updated by bmbouter over 4 years ago
- Status changed from NEW to ASSIGNED
- Assignee set to bmbouter
- Sprint set to Sprint 59
Adding as an AnsibleFest blocker.
Updated by bmbouter over 4 years ago
- Status changed from ASSIGNED to POST
PR available at: https://github.com/pulp/ansible-pulp/pull/153
Updated by bmbouter over 4 years ago
- Status changed from POST to MODIFIED
Applied in changeset ansible-pulp3|5a1615823e403db2fb3fa5b2b40941e54e555800.
Updated by bmbouter over 4 years ago
- Status changed from MODIFIED to CLOSED - CURRENTRELEASE
Updated by bmbouter almost 4 years ago
- Category set to Installer - Moved to GitHub issues
- Tags deleted (
Pulp 3 installer)
Add virtualenv /bin/ to systemd PATH
The systemd files did not manipulate the binary, so the Python import would be inside the virtualenv a call to
subprocess
would not.https://pulp.plan.io/issues/5474 closes #5474