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

k8s: reana user available system wide #328

Open
Sinclert opened this issue Aug 27, 2020 · 0 comments
Open

k8s: reana user available system wide #328

Sinclert opened this issue Aug 27, 2020 · 0 comments

Comments

@Sinclert
Copy link
Member

Sinclert commented Aug 27, 2020

Problem

When running an analysis that needs to obtain the user uname using the getpass Python library (pwd under the hood), the reana user that gets plugged by the workflow controller just before executing the desired workflow step, is not available neither within the /etc/passwd nor the /etc/shadow files.

Code snipped plugging reana user:

def _create_job_controller_startup_cmd(self, user=None):
"""Create job controller startup cmd."""
base_cmd = "flask run -h 0.0.0.0;"
if user:
add_group_cmd = "groupadd -f -g {} {};".format(
WORKFLOW_RUNTIME_USER_GID, WORKFLOW_RUNTIME_USER_GID
)
add_user_cmd = "useradd -u {} -g {} -M {};".format(
WORKFLOW_RUNTIME_USER_UID, WORKFLOW_RUNTIME_USER_GID, user
)
chown_workspace_cmd = "chown -R {}:{} {};".format(
WORKFLOW_RUNTIME_USER_UID,
WORKFLOW_RUNTIME_USER_GID,
SHARED_VOLUME_PATH + "/" + self.workflow.workspace_path,
)
run_app_cmd = 'su {} /bin/bash -c "{}"'.format(user, base_cmd)
full_cmd = add_group_cmd + add_user_cmd + chown_workspace_cmd + run_app_cmd
return [full_cmd]
else:
return base_cmd.split()


How I ran into the issue

I was designing a workflow that uses MLFlow to send information to a server to track specific information across multiple runs. When running the workflow, I encounter the following error:

  ...
  File "/usr/local/lib/python3.8/dist-packages/mlflow/tracking/context/default_context.py", line 19, in _get_user
    return getpass.getuser()
  File "/usr/lib/python3.8/getpass.py", line 169, in getuser
    return pwd.getpwuid(os.getuid())[0]
KeyError: 'getpwuid(): uid not found: 1000'

Possible solution

When looking for similar problems online, I found a couple of GitHub discussions about:

I think the issue could be solved by using the -r/--sytem flag on the useradd command, as the Linux manual describes.


I am not that familiar with the reana-workflow-controller, but I think it is a good guess.
Any feedback will be welcome 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant