che icon indicating copy to clipboard operation
che copied to clipboard

Che cannot create projects with SELinux enabled

Open utrescu opened this issue 10 years ago • 33 comments

In Eclipse Che 4.0.0-beta-13. Trying to create a simple project fails in Fedora 22 in the third stage "Injecting and starting workspace agent"

[STDERR] unzip: cannot find or open /mnt/che/ws-agent.zip, /mnt/che/ws-agent.zip.zip or /mnt/che/ws-agent.zip.ZIP.

After su -c "setenforce 0" all goes ok. And projects can be created without problem.

May be is a problem with volume labels in Docker? link

utrescu avatar Jan 27 '16 23:01 utrescu

Thank you for reporting this issue @utrescu. I do not believe we have run an integration test on Fedora to date. @garagatyi and @eivantsov will want to comment on this issue.

Did you start Che as a stand alone server or as Che running itself in a Docker container?

As a matter of background on what the system is attempting to do:

  1. We connect to github and download the appropriate image if it is not available locally.
  2. We create a container from that image.
  3. When the container is booted, we take a ws-agent.zip archive (which has a tomcat server inside of it), and mount it into the container. The location of the ws-agent.zip is defined by the che.properties file which is in /conf.
  4. After it is mounted, the container performs an unzip and then a launch of Tomcat.

So yes, the error you are getting seems to indicate that either the mount failed, or the ws-agent.zip wasn't in the location expected by the container (in order to mount it). This injection process happens after the container is started.

I think we need engineers to comment on more specifics. My suspicion this is due to an OS-specific issue.

TylerJewell avatar Jan 27 '16 23:01 TylerJewell

Upgraded to Fedora 23 and I have the same issue. I'm running Che as a stand alone server downloaded from the web with Docker version 1.9.1-fc23.

In this version, 1.9, Docker can mount shared folders without problems with SELinux (in older versions I need to label host dir manually chcon -Rt svirt_sandbox_file_t host_dir.)

$ docker run -v $PWD:/opt -ti ubuntu
root@2bb7becf76bc:/# Usage of loopback devices is strongly discouraged for production use.      
Either use `--storage-opt dm.thinpooldev` or use `--storage-opt dm.no_warn_on_loop_devices=true` to suppress this warning.
root@2bb7becf76bc:/# 
root@2bb7becf76bc:/# cd /opt/
root@2bb7becf76bc:/opt# ls
test.txt
root@2bb7becf76bc:/opt# cat test.txt
Ok

utrescu avatar Jan 28 '16 09:01 utrescu

Checked it with Fedora 23. Che started as expected. Anything else we can do to reproduce the issue?

ghost avatar Jan 28 '16 12:01 ghost

in my case, che started but failed to create new workspace. It failed in step "Injecting and starting workspace agent" as @utrescu said.

veparkki avatar Jan 28 '16 14:01 veparkki

I just downloaded the package from here, unzip it, and start Che

$ ./che.sh start

I go to http://localhost:8080 and tried to create a simple project in Java ...

In the Tomcat logs the only error are "Workspace Agent is not responding"...

2016-01-28 15:11:31,741[kspaceManager-1]  [INFO ] [o.e.c.a.m.s.MachineManager 167]      - Creating machine [ws = workspace8mla55fsiwrn1u9z: env = wksp-vyym: machine = ws-machine]
2016-01-28 15:11:36,363[kspaceManager-1]  [WARN ] [o.e.c.p.d.c.DockerConnector 1099]    - Error response from docker API, status: 200, message: Usage of loopback devices is strongly discouraged for production use. Either use `--storage-opt dm.thinpooldev` or use `--storage-opt dm.no_warn_on_loop_devices=true` to suppress this warning.

2016-01-28 15:12:36,412[kspaceManager-1]  [ERROR] [o.e.c.a.w.s.WorkspaceManager 615]    - Workspace agent is not responding. Workspace workspace8mla55fsiwrn1u9z will be stopped
org.eclipse.che.api.machine.server.exception.MachineException: Workspace agent is not responding. Workspace workspace8mla55fsiwrn1u9z will be stopped
at org.eclipse.che.api.machine.server.MachineManager.createInstance(MachineManager.java:396) ~[che-core-api-machine-4.0.0-beta-13.jar:4.0.0-beta-13]
at org.eclipse.che.api.machine.server.MachineManager.createMachine(MachineManager.java:337) ~[che-core-api-machine-4.0.0-beta-13.jar:4.0.0-beta-13]
at org.eclipse.che.api.machine.server.MachineManager.createMachineSync(MachineManager.java:168) ~[che-core-api-machine-4.0.0-beta-13.jar:4.0.0-beta-13]
at org.eclipse.che.api.workspace.server.RuntimeWorkspaceRegistry.createMachine(RuntimeWorkspaceRegistry.java:451) ~[che-core-api-workspace-4.0.0-beta-13.jar:4.0.0-beta-13]
at org.eclipse.che.api.workspace.server.RuntimeWorkspaceRegistry.startEnvironment(RuntimeWorkspaceRegistry.java:319) ~[che-core-api-workspace-4.0.0-beta-13.jar:4.0.0-beta-13]
at org.eclipse.che.api.workspace.server.RuntimeWorkspaceRegistry.start(RuntimeWorkspaceRegistry.java:145) ~[che-core-api-workspace-4.0.0-beta-13.jar:4.0.0-beta-13]
at org.eclipse.che.api.workspace.server.WorkspaceManager.performSyncStart(WorkspaceManager.java:642) ~[che-core-api-workspace-4.0.0-beta-13.jar:4.0.0-beta-13]
at org.eclipse.che.api.workspace.server.WorkspaceManager.lambda$performAsyncStart$9(WorkspaceManager.java:613) ~[che-core-api-workspace-4.0.0-beta-13.jar:4.0.0-beta-13]
at org.eclipse.che.commons.lang.concurrent.CopyThreadLocalRunnable.run(CopyThreadLocalRunnable.java:28) ~[che-core-commons-lang-4.0.0-beta-13.jar:4.0.0-beta-13]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_65]
at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_65]
Caused by: org.eclipse.che.api.machine.server.exception.MachineException: Workspace agent is not responding. Workspace workspace8mla55fsiwrn1u9z will be stopped
at org.eclipse.che.api.machine.server.WsAgentLauncherImpl.startWsAgent(WsAgentLauncherImpl.java:104) ~[che-core-api-machine-4.0.0-beta-13.jar:4.0.0-beta-13]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_65]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_65]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_65]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_65]
at com.google.inject.internal.DelegatingInvocationHandler.invoke(DelegatingInvocationHandler.java:50) ~[guice-4.0.jar:na]
at com.sun.proxy.$Proxy52.startWsAgent(Unknown Source) ~[na:na]
at org.eclipse.che.api.machine.server.MachineManager.createInstance(MachineManager.java:370) ~[che-core-api-machine-4.0.0-beta-13.jar:4.0.0-beta-13]
... 11 common frames omitted

Same problem in the machineId.logs

$ cat machineId.logs 
[DOCKER] Step 1 : FROM codenvy/ubuntu_jdk8
[DOCKER] Trying to pull repository docker.io/codenvy/ubuntu_jdk8 ...
[DOCKER] latest: Pulling from codenvy/ubuntu_jdk8 
[DOCKER] Digest:     sha256:1810ba46e7ed2451013a24efe39db43de1df071fd6ae7e615c378953db124c90 
[DOCKER] Status: Image is up to date for docker.io/codenvy/ubuntu_jdk8:latest 
[DOCKER] 
[DOCKER] ---> 7d21e23fb385
[DOCKER] Successfully built 7d21e23fb385
[ERROR] Workspace agent is not responding. Workspace workspace8mla55fsiwrn1u9z will be stopped

utrescu avatar Jan 28 '16 14:01 utrescu

I have this in my jounalctl logs:

Jan 28 16:50:01 x3.home setroubleshoot[27084]: SELinux is preventing unzip from open access on the file /mnt/che/ws-agent.zip. For complete SELinux messages. run sealert -l 480b406d-67aa-4461-a
Jan 28 16:50:01 x3.home python3[27084]: SELinux is preventing unzip from open access on the file /mnt/che/ws-agent.zip.

                                        *****  Plugin catchall (100. confidence) suggests   **************************

                                        If you believe that unzip should be allowed open access on the ws-agent.zip file by default.
                                        Then you should report this as a bug.
                                        You can generate a local policy module to allow this access.
                                        Do
                                        allow this access for now by executing:
                                        # grep unzip /var/log/audit/audit.log | audit2allow -M mypol
                                        # semodule -i mypol.pp

veparkki avatar Jan 28 '16 14:01 veparkki

I have this issue when running che server on Mac OSX 10.11.2 as well.

I started server using

/opt/eclipse-che-4.0.0-beta-13/bin/che.sh start

ayubmalik avatar Jan 29 '16 10:01 ayubmalik

Same issue here on Fedora 23. Disabling SELinux resolved the issue.

kaloyan-raev avatar Jan 31 '16 13:01 kaloyan-raev

@ayubmalik can you elaborate on the issue you are facing? Any logs/stacktrace?

@kaloyan-raev, can you please help us investigate? We have tried it with SELinux enabled on 2 Fedora systems - no issues found. Probably, it has smth to do with some local settings. If possible, enable SELinux, start a workspace and run two commands :

id ps axZ | grep java

Also, you may want trying the following solution http://stackoverflow.com/a/24334000/2331089 where path to mount folder is /lib/ws-agent.zip (you will find it in the assembly)

ghost avatar Feb 01 '16 07:02 ghost

I reverted enabled back SELinux and tried to create a new repository, which failed with "Machine destoryed" during startup.

Here is the output of the two commands:

[kraev@ThinkPad eclipse-che-4.0.0-beta-13]$ id
uid=1000(kraev) gid=1000(kraev) groups=1000(kraev),10(wheel),976(vboxusers),1001(docker) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[kraev@ThinkPad eclipse-che-4.0.0-beta-13]$ ps axZ | grep java
unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 4049 pts/0 Sl+   0:20 /usr/lib/jvm/java-1.8.0/bin/java -Djava.util.logging.config.file=/home/kraev/Work/eclipse-che-4.0.0-beta-13/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dport.http=8080 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dche.local.conf.dir=/home/kraev/Work/eclipse-che-4.0.0-beta-13/conf/ -Dche.home=/home/kraev/Work/eclipse-che-4.0.0-beta-13 -Dche.logs.dir=/home/kraev/Work/eclipse-che-4.0.0-beta-13/tomcat/logs/ -Djava.endorsed.dirs=/home/kraev/Work/eclipse-che-4.0.0-beta-13/tomcat/endorsed -classpath /home/kraev/Work/eclipse-che-4.0.0-beta-13/tomcat/conf/:/usr/lib/jvm/java-1.8.0/lib/tools.jar:/home/kraev/Work/eclipse-che-4.0.0-beta-13/tomcat/bin/bootstrap.jar:/home/kraev/Work/eclipse-che-4.0.0-beta-13/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/home/kraev/Work/eclipse-che-4.0.0-beta-13/tomcat -Dcatalina.home=/home/kraev/Work/eclipse-che-4.0.0-beta-13/tomcat -Djava.io.tmpdir=/home/kraev/Work/eclipse-che-4.0.0-beta-13/tomcat/temp org.apache.catalina.startup.Bootstrap start
unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 4646 pts/1 S+   0:00 grep --color=auto java

kaloyan-raev avatar Feb 01 '16 12:02 kaloyan-raev

@eivantsov I tried applying the workaround from StackOverflow. I executed the following command just before starting the Che server:

chcon -Rt svirt_sandbox_file_t /home/kraev/Work/eclipse-che-4.0.0-beta-13/lib/ws-agent.zip

But it did not help.

kaloyan-raev avatar Feb 01 '16 12:02 kaloyan-raev

@eivantsov
My environment is

  • MacOSX 10.11.2
  • Boot2Docker 1.8.3
  • Java 1.8.0_60 (Oracle)

I started che using /opt/eclipse-che-4.0.0-beta-13/bin/che.sh start Then tried to create new Node project from sample and get following error. Output is as follows

[DOCKER] ec60570de52d: Already exists 
[DOCKER] Digest: sha256:73f257d9ecf5cac00cfb3a931a352c20d5b2e59a9f5828f1fc309ed85314ffaa 
[DOCKER] Status: Image is up to date for codenvy/node:latest 
[DOCKER] ---> ec60570de52d
[DOCKER] Successfully built ec60570de52d

[STDERR] unzip:  cannot find or open /mnt/che/ws-agent.zip, /mnt/che/ws-agent.zip.zip or /mnt/che/ws-agent.zip.ZIP.
[ERROR] Workspace agent is not responding. Workspace workspace33ne1qbdrjaxcdcs will be stopped

Will try your suggested fix...

ayubmalik avatar Feb 01 '16 12:02 ayubmalik

same issue here with the most recent beta, when creating console-java-simple, stuck at step 3 - Injecting and starting workspace agent

[STDERR]

unzip: cannot find or open /mnt/che/ws-agent.zip, /mnt/che/ws-agent.zip.zip or /mnt/che/ws-agent.zip.ZIP.

Console stack trace:

2016-02-01 23:54:08,279[main]             [INFO ] [o.a.catalina.startup.Catalina 638]   - Server startup in 4141 ms
2016-02-02 10:10:12,218[nio-8080-exec-9]  [INFO ] [o.e.c.a.w.s.WorkspaceManager 277]    - EVENT#workspace-remove# WS-ID#workspaceyq0hh575s3cg2e1s#
2016-02-02 10:16:30,040[nio-8080-exec-9]  [INFO ] [o.e.c.a.w.s.WorkspaceManager 144]    - EVENT#workspace-created# WS#wksp-2efn# WS-ID#workspacen68e7qs5n2cu8v6r# USER#che#
2016-02-02 10:16:31,090[kspaceManager-0]  [INFO ] [o.e.c.a.m.s.MachineManager 167]      - Creating machine [ws = workspacen68e7qs5n2cu8v6r: env = wksp-2efn: machine = ws-machine]
2016-02-02 10:17:33,768[kspaceManager-0]  [ERROR] [o.e.c.a.w.s.WorkspaceManager 615]    - Workspace agent is not responding. Workspace workspacen68e7qs5n2cu8v6r will be stopped
org.eclipse.che.api.machine.server.exception.MachineException: Workspace agent is not responding. Workspace workspacen68e7qs5n2cu8v6r will be stopped
    at org.eclipse.che.api.machine.server.MachineManager.createInstance(MachineManager.java:396) ~[che-core-api-machine-4.0.0-beta-13.jar:4.0.0-beta-13]
    at org.eclipse.che.api.machine.server.MachineManager.createMachine(MachineManager.java:337) ~[che-core-api-machine-4.0.0-beta-13.jar:4.0.0-beta-13]
    at org.eclipse.che.api.machine.server.MachineManager.createMachineSync(MachineManager.java:168) ~[che-core-api-machine-4.0.0-beta-13.jar:4.0.0-beta-13]
    at org.eclipse.che.api.workspace.server.RuntimeWorkspaceRegistry.createMachine(RuntimeWorkspaceRegistry.java:451) ~[che-core-api-workspace-4.0.0-beta-13.jar:4.0.0-beta-13]
    at org.eclipse.che.api.workspace.server.RuntimeWorkspaceRegistry.startEnvironment(RuntimeWorkspaceRegistry.java:319) ~[che-core-api-workspace-4.0.0-beta-13.jar:4.0.0-beta-13]
    at org.eclipse.che.api.workspace.server.RuntimeWorkspaceRegistry.start(RuntimeWorkspaceRegistry.java:145) ~[che-core-api-workspace-4.0.0-beta-13.jar:4.0.0-beta-13]
    at org.eclipse.che.api.workspace.server.WorkspaceManager.performSyncStart(WorkspaceManager.java:642) ~[che-core-api-workspace-4.0.0-beta-13.jar:4.0.0-beta-13]
    at org.eclipse.che.api.workspace.server.WorkspaceManager.lambda$performAsyncStart$9(WorkspaceManager.java:613) ~[che-core-api-workspace-4.0.0-beta-13.jar:4.0.0-beta-13]
    at org.eclipse.che.commons.lang.concurrent.CopyThreadLocalRunnable.run(CopyThreadLocalRunnable.java:28) ~[che-core-commons-lang-4.0.0-beta-13.jar:4.0.0-beta-13]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_71]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_71]
    at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_71]
Caused by: org.eclipse.che.api.machine.server.exception.MachineException: Workspace agent is not responding. Workspace workspacen68e7qs5n2cu8v6r will be stopped
    at org.eclipse.che.api.machine.server.WsAgentLauncherImpl.startWsAgent(WsAgentLauncherImpl.java:104) ~[che-core-api-machine-4.0.0-beta-13.jar:4.0.0-beta-13]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_71]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_71]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_71]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_71]
    at com.google.inject.internal.DelegatingInvocationHandler.invoke(DelegatingInvocationHandler.java:50) ~[guice-4.0.jar:na]
    at com.sun.proxy.$Proxy52.startWsAgent(Unknown Source) ~[na:na]
    at org.eclipse.che.api.machine.server.MachineManager.createInstance(MachineManager.java:370) ~[che-core-api-machine-4.0.0-beta-13.jar:4.0.0-beta-13]
    ... 11 common frames omitted

My environment:

Docker version 1.9.1, build a34a1d5
Java version "1.8.0_71"
MacOSX 10.9.5

p4ali avatar Feb 02 '16 18:02 p4ali

I am also suffering this bug.

I am using Che directly from the docker image at codenvy/che:latest, and I'm running Fedora 23 and latest Docker.

[ssaavedra@andromeda]~% uname -r
4.3.5-300.fc23.x86_64
[ssaavedra@andromeda]~% docker --version
Docker version 1.10.1, build 9e83765

I tried two different strategies at launching Che.

  1. I tried the naïve (unsupported) one of just docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock codenvy/che, which did not work, first beause the GID of the docker group inside the container did not match the hosts' so it could not get to the docker sock.

That is solved by adding --group-add=getent group docker|cut -d: -f3`` so just assume I add that to all the docker run commands.

I also tried to run the long line at your docs:

docker run -ti --net=host 
           -v /var/run/docker.sock:/var/run/docker.sock 
           -v /home/user/che/lib:/home/user/che/lib-copy 
           -v /home/user/che/workspaces:/home/user/che/workspaces 
           -v /home/user/che/tomcat/temp/local-storage:/home/user/che/tomcat/temp/local-storage 
           codenvy/che

In any of those two ways (mounting or not /home/user/che) it works.

But when I create a project (everything default options), it complains about not finding the ws-agent.zip.

unzip: cannot find or open /mnt/che/ws-agent.zip, /mnt/che/ws-agent.zip.zip or /mnt/che/ws-agent.zip.ZIP.

So, I look via docker inspect <container-id-of-workspace> and I see that /mnt/che/ws-agent.zip is a mount from /home/user/che/lib/ws-agent.zip no matter whether I used the bind mount or not when invoking Che from docker.

When I inspect the mount at the host (which should not happen IMHO if I am running everything inside Docker) I find that docker has just created a folder named ws-agent.zip which is empty.

Any fix?

ssaavedra avatar Feb 18 '16 15:02 ssaavedra

Can you run Che natively and see if this can be reproduced? What happens if you disable selinux?

ghost avatar Feb 18 '16 16:02 ghost

I have just found a workaround, inside dockerized che.

Not pretty, but it makes the trick. Using the long call that I said before was in the docs, now host's /home/user/che/lib should contain container's /home/user/che/lib-copy. Which is not what it should, but oddly enough, container's /home/user/che/lib contains the right ws-agent.zip (a zip file). Thus, the following is a workaround:

  1. Start the container, mounting container's /home/user/che/lib-copy in host's /home/user/che/lib
  2. docker exec -it <che-id> bash while running the container, go to /home/user/che
  3. rmdir lib-copy/ws-agent.zip
  4. cp lib/ws-agent.zip lib-copy/ws-agent.zip
  5. Done! (exit the inner bash)

Now I can create a project and it correctly inflates ws-agent.zip (which gets mounted onto the ws docker container from the host's).

I would hope it would not be very difficult to declare a in the Dockerfile for che (or maybe a data container shared by both che and the ws containers) so that you could run the ws containers with --volumes-from=che-ws-agent .

ssaavedra avatar Feb 18 '16 16:02 ssaavedra

Isn't it what we do in https://github.com/eclipse/che/blob/master/Dockerfile#L27?

Yes, volumes-from is what we are thinking about now.

ghost avatar Feb 18 '16 16:02 ghost

It seems to be. But empiric inspection proves otherwise.

How can we debug this?

ssaavedra avatar Feb 18 '16 16:02 ssaavedra

How did you start the container? With our CMD or with yours?

ghost avatar Feb 18 '16 16:02 ghost

Yours (with added --group-add=977 in my case, after shell expansion).

ssaavedra avatar Feb 18 '16 16:02 ssaavedra