Skip to content
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

Catch python error when unable to find user #2924

Merged
merged 1 commit into from
Dec 13, 2018

Conversation

AlanCoding
Copy link
Member

SUMMARY

I need to be able to run commands in containers as root, and with the recent container permission changes this was failing.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME
  • API
AWX VERSION

ADDITIONAL INFORMATION

Shell into node in cluster as root

docker exec --user=0 -it tools_awx_1_1 /bin/bash

then management commands don't work

bash-4.2# awx-manage
Traceback (most recent call last):
  File "/usr/local/bin/awx-manage", line 9, in <module>
    load_entry_point('awx', 'console_scripts', 'awx-manage')()
  File "/awx_devel/awx/__init__.py", line 134, in manage
    prepare_env()
  File "/awx_devel/awx/__init__.py", line 89, in prepare_env
    if not settings.DEBUG: # pragma: no cover
  File "/venv/awx/lib/python2.7/site-packages/django/conf/__init__.py", line 56, in __getattr__
    self._setup(name)
  File "/venv/awx/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup
    self._wrapped = Settings(settings_module)
  File "/venv/awx/lib/python2.7/site-packages/django/conf/__init__.py", line 110, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/awx_devel/awx/settings/development.py", line 138, in <module>
    include(optional('local_*.py'), scope=locals())
  File "/venv/awx/lib/python2.7/site-packages/split_settings/tools.py", line 102, in include
    exec(compile(to_compile.read(), included_file, 'exec'), scope)
  File "/awx_devel/awx/settings/local_settings.py", line 274, in <module>
    TEST_SSH_LOOPBACK_USERNAME = getpass.getuser()
  File "/usr/lib64/python2.7/getpass.py", line 158, in getuser
    return pwd.getpwuid(os.getuid())[0]
KeyError: 'getpwuid(): uid not found: 0'

The use of this setting is for tests

acc9742

Those tests no longer exist, we could delete the entire section of the settings, but right now I just want it to not error.

The root appears to be that there is no entry for the root user in /etc/passwd, cms-dev/isolate#25... I don't really want to dive into that either.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (gate pipeline).

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit e6f654b into ansible:devel Dec 13, 2018
@AlanCoding AlanCoding deleted the run_as_root branch January 14, 2019 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants