question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Most public images used in devfile registry do not work as the base for Che 7 workspaces on OpenShift

See original GitHub issue

Description

OpenShift by default starts containers using a random UID for security purposes [1]. Since the UID to be used is not known at container creation time, there is no entry for the running user in /etc/passwd.

This can cause a multitude of problems:

  • The terminal is buggy: tab completion does not work, pressing up arrow does not work
    • Default terminal is always /bin/sh; starting bash results in the prompt I have no name!@workspaceid $
    • User does not have a home directory, and terminal does not open to /projects
  • Any program that depends on user id or home directory can have issues
  • Some configuration that relies on having a home directory is impossible, and behaviour in these cases is generally unpredictable.

The suggestions in [1] are

  • Any directory that needs to be accessed must have read/write permissions for the root group. This is not a problem for directories mounted as volumes
  • The /etc/passwd file should be writable by the root group. Then, an entrypoint script can execute something like
    if ! whoami &> /dev/null; then
      if [ -w /etc/passwd ]; then
        echo "${USER_NAME:-default}:x:$(id -u):0:${USER_NAME:-default} user:${HOME}:/sbin/nologin" >> /etc/passwd
      fi
    fi
    
    to set the current user correctly.

The second point above is the issue – images not created to run on OpenShift do not have a writeable /etc/passwd; further, since we normally overwrite container commands with sleep infinity or tail -f /dev/null, even images with an entrypoint that does what we need won’t execute the script by default. Note that this is what’s done when starting the default “Che 7” stack, which explains why it works.

At this time, I don’t see many good potential solutions; when running on OpenShift, the Che server could attempt to rewrite the recipe’s container commands with the script above followed by whichever non-terminating command we like, but this would still require using compatible images in the devfile registry. It could also result in confusing errors if we’re automatically rewriting entrypoints, and it’s difficult to specify a script like above in the yaml list format used for container commands.

I’m currently working with trying to implement the above, but if anyone has better ideas, it’d be great to hear them.

[1]- https://docs.okd.io/3.11/creating_images/guidelines.html#openshift-specific-guidelines

Reproduction Steps

Start a Che 7 workspace other than the default dev image (e.g. java-maven), open a terminal, and type whoami

OS and version:
Che 7 on any OpenShift

Diagnostics: In most images, we have e.g.:

$ id
uid=1075080000 gid=0(root) groups=0(root),1075080000

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
ibuziukcommented, Jul 24, 2019

@amisevsk I reworded this issue a bit to make it Che 7 specific. WDYT about closing this one and creating a separate one for the general use-case of public images as a language runtime on OpenShift? I believe we need to cross-link this new general issue with https://github.com/openshift/origin/issues/23369

1reaction
amisevskcommented, Jul 22, 2019

@ibuziuk, speaking of split discussion: https://github.com/eclipse/che-devfile-registry/pull/38#issuecomment-513729389

I’ll open a PR to use a more convenient base image.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chapter 1. Customizing the devfile and plug-in registries
The my-plug-in-registry and my-devfile-registry images used in this section are built using the docker command. This section assumes that these images are ......
Read more >
Introduction to Devfile - GitHub Pages
The minimal devfile sufficient to run a workspace from it, consists of the ... The simplest way to use devfile is to have...
Read more >
Introduction to Eclipse Che :: Eclipse Che Documentation
A centralized developer environment running on Kubernetes or OpenShift. A multi-container workspace for each developer with the ability to replicate with a ...
Read more >
eclipse che docker desktop installation is unable to pull ...
Withing Che, you can't configure your credentials to be used for every user. Each is supposed to configure their credentials, ...
Read more >
Customizing IBM Wazi Developer for Workspaces devfile ...
Build the Docker image that is specified in the supplied Dockerfile , and push the image to a public container registry. If the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found