eclipse-che / che

Kubernetes based Cloud Development Environments for Enterprise Teams
http://eclipse.org/che
Eclipse Public License 2.0
6.96k stars 1.19k forks source link

Failed to change port (regression) #3179

Closed ne0h closed 7 years ago

ne0h commented 7 years ago

Hi, I do not manage to get che running with a non-default port (9080). I tried on Arch Linux and Ubuntu 14.04 LTS. 8080 works but changing the port via export CHE_PORT=9080 does not work. Error message in the terminal where I start docker:

INFO: ECLIPSE CHE: Found image eclipse/che-server:5.0.0-latest
INFO: ECLIPSE CHE: Starting container...
INFO: ECLIPSE CHE: Server logs at "docker logs -f che-server"
INFO: ECLIPSE CHE: Server booting...
---------------------------------------
ERROR: !!!
ERROR:      ECLIPSE CHE: Timeout waiting for server. Run "docker logs che-server" to inspect the issue.
ERROR: !!!
---------------------------------------

Docker log is attached here: https://gist.github.com/ne0h/7e07dd868bdb2a8fc42130471be261b0

Reproduction Steps:

  1. Follow the guide: https://www.eclipse.org/che/getting-started/download/ to download the startup file
  2. export CHE_PORT=9080
  3. che start

Expected behavior:

Everything is fine.

Observed behavior:

Che "does not come up".

Che version: 5.0.0-latest
OS and version:Ubuntu 14.04 LTS, Arch Linux
Docker version: 1.12.3, build 6b644ec Che install: Docker container

Additional information:

Thanks in advance! Max

TylerJewell commented 7 years ago

Maximillian - I am investigating. In the mean time, you can bypass the CLI and [launch the server] (https://eclipse-che.readme.io/docs/usage-docker-server) with this Docker syntax. And you can override the ports more directly with that.

TylerJewell commented 7 years ago

Confirmed the issue with che-launcher. There is an adaptaptation regression that is causing some sort of variable passing error.

TylerJewell commented 7 years ago

@ne0h - found the issue and got a fix in. This will show up in our nightly's shortly.

https://github.com/eclipse/che-dockerfiles/pull/50#pullrequestreview-10216972

TylerJewell commented 7 years ago

@ne0h - CI systems updated and this issue should no longer be active.

ne0h commented 7 years ago

@TylerJewell - Thanks a lot for your work!

Are sure that the bug is fixed? I am getting the same error even with CHE_VERSION=nightly. I tried docker run --rm -t -v /var/run/docker.sock:/var/run/docker.sock -e CHE_PORT=9080 -e CHE_VERSION=nightly eclipse/che:nightly start and CHE_PORT=9080 CHE_VERSION=nightly che start.

lsof -i :9080 shows that there is "something" running on 9080:

COMMAND     PID USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
docker-pr 10626 root    4u  IPv6 10978498      0t0  TCP *:9080 (LISTEN)

But there is still nothing to access on http://localhost:9080. Same on Archlinux and Ubuntu.

TylerJewell commented 7 years ago

Yes the issue is fixed. It is fixed in a utility so please set CHE_UTILITY_VERSION to nightly first.

ne0h commented 7 years ago

So it works for you?

I am still getting the same error with CHE_PORT=9080 CHE_UTILITY_VERSION=nightly che start. No difference if passing the environment variables directly or using export.

TylerJewell commented 7 years ago

Yes, it is working for me. Chances are your old images are cached. This happens a lot when using the "nightly" images. You should start by doing docker rmi -f $(docker images -q) to remove all of the images on your system and then try again.

ne0h commented 7 years ago

Ah your absolutely right - works like a charm now. Thanks a lot for your patience and fast responses!

orboan commented 7 years ago

Hello, trying to change the default port and reaching this thread.

I run this:

docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v ~/data/che:/data -e CHE_HOST=${HOST} -e CHE_PORT=${PORT} -e CHE_UTILITY_VERSION=nightly -e CHE_VERSION=nightly eclipse/che:nightly start

(The environment variables for port and host are correctly set.)

And I get:

INFO: (che cli): Pulling image alpine:3.4 INFO: (che cli): Pulling image eclipse/che-ip:nightly INFO: (che cli): Loading cli... ERROR: ERROR: Your CLI version 'eclipse/che:nightly' does not match your installed version '5.0.0'. ERROR: ERROR: The 'nightly' CLI is only compatible with 'nightly' installed versions. ERROR: You may not 'che upgrade' from 'nightly' to a numbered (tagged) version. ERROR: ERROR: Run the CLI as 'eclipse/che:<version>' to install a tagged version.

And yes, I removed first all docker images.

So, what am I missing?

Thanks.

TylerJewell commented 7 years ago

It looks like the files that you have in ~/data/che were originally installed with the 5.0.0 version of Che. It means that you ran docker run eclipse/che.

The nightly version is not compatible with non-nightly versions. So if you try to use eclipse/che:nightly as the version, we check the installation folder and if it is also not a nightly then we fail. We do this because the nightly is essnetially like a development channel, and it changes frequently with no guarantee of underlying data integrity.

You either need to run the nightly in a new folder, or to destroy the installation you have first before running again.

# Destroy an installation
docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock 
  -v ~/data/che:/data eclipse/che:nightly destroy

# Create new installation and start with a port
docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock 
  -v ~/data/che:/data -e CHE_HOST=${HOST} -e CHE_PORT=${PORT} 
   eclipse/che:nightly start

Note the CHE_VERSION and CHE_UTILITY_VERSION no longer apply with this new CLI. You can just run "docker run eclipse/che" to get help. We have greatly simplified the CLI.

tkausl commented 7 years ago

I still have this problem, looking through the cli log, the server isn't started directly but through docker-compose using a generated yml file. This yml still uses the wrong port (8080): https://github.com/eclipse/che/blob/master/dockerfiles/init/modules/compose/templates/docker-compose.yml.erb

TylerJewell commented 7 years ago

The YML is set to the CHE_HOST port. It maps the external port of the container to the internal port, 8080. We do not yet have logic that simplifies changing the intenral port of the Tomcat in the container, but why should that matter? The container's exposed port is changed.

I just tested this with nightly on windows 10 and it was ok.

tkausl commented 7 years ago

Well tomcat seems to always listen on the CHE_PORT for me so mapping to the internal port 8080 isn't working

part of docker logs che:

2017-01-12 16:47:30,146[main]             [INFO ] [o.a.c.s.VersionLoggerListener 115]   - Command line argument: -Dport.http=8181

https://github.com/eclipse/che/blob/master/dockerfiles/che/entrypoint.sh#L155

TylerJewell commented 7 years ago

Humm - can you share Che version you ran for this, too - was it nightly? Thx.

tkausl commented 7 years ago

It was nightly, yes. And eclipse/che, not eclipse/che-cli if this matters

TylerJewell commented 7 years ago

Ok - thanks for the report - will do a proper investigation this weekend.

orboan commented 7 years ago

Thanks TylerJewell

TylerJewell commented 7 years ago

Well, I have uncovered the root cause.

When you run the CLI with -e CHE_PORT=<num>, we purposely do not include CHE_PORT into the che.env. As a result, CHE_PORT should not be passed from the CLI into the eclipse/che-server container as an environment variable (we pass the entire che.env file into the new container when it is started). We then make assumptions that CHE_PORT is not passed into the new container, and therefore it should be hard-coded to 8080 inside of the che-server container and then your custom port exposed.

However, when starting Che with the latest tagged release and inspecting the container, CHE_PORT with the custom value is passed in. This, of course, breaks the template, which is just mapping the external custom port to the hard-coded internal port.

This is happening because we are actually passing in two separate che.env files. There is the user's configured che.env but there seems to be a secondary /instance/config/che.env file that we generate internally that is also passed in. This secondary che.env is set from this template https://github.com/eclipse/che/blob/master/dockerfiles/init/modules/che/templates/che.env.erb and it has CHE_PORT included within it. So while I assumed CHE_PORT was never passed in, looks like @benoitf updated the configuration to make sure it's always passed in.

So the solution is to either revert CHE_PORT out of the secondary puppet template. Or to update the docker-compose template to do an internal mapping of the CHE_PORT.

TylerJewell commented 7 years ago

I also note that in https://github.com/eclipse/che/blob/master/dockerfiles/init/modules/che/templates/che.env.erb that CHE_PORT is added twice. There is a function at the top that loopse through all in-memory variables with CHE_* set and then a hard-coded list of additional CHE_* variables. So if CHE_PORT is in memory, then it will always be added to this file, even if we remove the hard-coded variant.

So seems simplest fix will be to update the template to make the internal Che server respect the port parameter.

TylerJewell commented 7 years ago

https://github.com/eclipse/che/pull/3734

To make this work temporarily until this makes it into the nightly stream:

  1. git clone http://github.com/eclipse/che
  2. git checkout CHE-3179
  3. cd dockerfiles/init; bash build.sh
  4. cd dockerfiles/cli; bash build.sh

This should generate a new eclipse/che:nightly image that has this correction. You can then use a custom port.