-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Use a docker launcher image to simplify start/stop/update/restart commands #1683
Conversation
658d34e
to
abd2488
Compare
Can one of the admins verify this patch? |
# `docker run --rm \ | ||
# -v /var/run/docker.sock:/var/run/docker.sock \ | ||
# codenvy/che-launcher [start|stop|restart|update] | ||
FROM docker:1.11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If user has docker 1.10 or 1.12 on his machine/server, will he get exception due to incompatible docker client/server?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a problem. I've tested it with 1.12rc2 and it worked but I got the exception with v1.10. I can think about 2 possible solutions:
- Mount the docker binary as well:
docker run -v $(which docker):/usr/local/bin/docker -v /var/run/docker.sock:/var/run/docker.sock codenvy/che-launcher start
- Use a tool like dvm to install multiple Docker clients in the image and update
launch.sh
to test which docker client works well.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also support several tags of launcher image with different versions of docker. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would you tag these images with different Docker version? codenvy/che-launcher:release-docker1.11
?
My main concern is that users should check their Docker version before running Che and adapt the docker run
command accordingly. I would prefer copy/paste a simple command without any editing.
Let me check what Rancher and Docker UCP do because they must have the same problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The $(which docker)
syntax will fail on Docker for Windows. But you can do a string parse using docker version
. There is go format syntax accepted as part of the command. But this does seem like an inelegant solution. All this work to simplify the run syntax to just introduce a complicated mount to handle the docker client binary.
Seems like we need to embed smart logic within the launcher.sh to figure out what docker daemon version is running, test for version compatibility, and then use the right docker client within the launcher.
I am such a huge fan of this approach to simplifying the run syntax. I think we have to develop a strategy that inverses some of the files.
One issue with this approach is that it is not easy to build the images. The server Dockerfile assumes that there is a Che assembly in a certain sub-directory. Also the file naming becomes inconsistent.
|
|
||
for command_line_option in "$@" | ||
do | ||
case ${command_line_option} in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I prefer leaving do
in the same line where for
is placed and addition of indentation of body of cycle.
It makes shell script more similar to java code. Please consider such reformatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
I like simplified Che management approach. Good job, @l0rd! Here are some possible improvements (not obviously for that PR):
|
I'm not sure how launcher container will behave if user call start of the server and then press @l0rd Can you clarify? |
@garagatyi thanks for your feedback! I will made changes accordingly and answer to your questions tomorrow. |
grep 'inet ' | \ | ||
cut -d/ -f1 | \ | ||
awk '{ print $2}') | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with docker for mac it returns the correct ip (I tried with both implementations)
but it doesn't work with docker toolbox for mac
$ docker run --rm --net host alpine sh -c ifconfig
docker0 Link encap:Ethernet HWaddr 02:42:BD:D7:32:B8
inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::42:bdff:fed7:32b8%32597/64 Scope:Link
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:49 errors:0 dropped:0 overruns:0 frame:0
TX packets:39 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:4277 (4.1 KiB) TX bytes:5483 (5.3 KiB)eth0 Link encap:Ethernet HWaddr 08:00:27:A2:AF:A6
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fea2:afa6%32597/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3609 errors:0 dropped:0 overruns:0 frame:0
TX packets:1934 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2580871 (2.4 MiB) TX bytes:159603 (155.8 KiB)eth1 Link encap:Ethernet HWaddr 08:00:27:70:6A:D8
inet addr:192.168.99.100 Bcast:192.168.99.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe70:6ad8%32597/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1170 errors:0 dropped:0 overruns:0 frame:0
TX packets:909 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:182053 (177.7 KiB) TX bytes:265568 (259.3 KiB)lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1%32597/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
the working ip is 192.168.99.100 (eth1) in my case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benoitf thanks for testing. I'll look at that.
Che server container is now started in background (
Let me add a function in |
@l0rd - if you launch the server in the background where people cannot get the logs, should we:
|
@TylerJewell Would you think a message like the following would help?
|
Yeah, definitely that is super useful. I think that combined with the test to verify the server is up, and the printout of the client URL is perfect. |
@l0rd - Based upon this comment, it dawns on me that we have many people who are running into issues because the directory where /lib-copy will get mounted is not writable. In one case, i saw a windows user who just didn't have his directory activated for mounting. And in a second case, the directory was mountable but not writable. Should we put in a check to test to make sure that the directories are writable for the following two locations? If these values are not provided in a che.properties, then we are using ${che.home}. If they are provided, then they are overrides. If you do not have write permissions to these folders, this is when the /mnt errors show up, and they are very mysterious to most people.
|
@TylerJewell I think you also need a configuration for the machine-workspaces location... |
|
||
# See: https://sipb.mit.edu/doc/safe-shell/ | ||
set -e | ||
trap exit SIGHUP SIGINT SIGTERM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about moving these lines to line 109, WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you don't have exit function in this script you don't need trapping
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And actually script fails because of bad trapping on my machine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@garagatyi I agree. Do we have the same issue in che.sh
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we have the same bug in che.sh
Hi @l0rd - I have started a list of to-dos, and also started to lay down some of the requirements that I think we need to zero in on for this to be mergeable. Note - this comment has been heavily edited. We now reference #1697 for the broader checklist of items to complete.
The repository of Che would be restructured as:
We would remove the default Dockerfile out of the root of the repository and place it in the right /dockerfiles folder. List of environment variables for launcher:
For the policy on che.properties. We can allow the user to pass in an environment variable which provides a fully qualified path to a local che.properties file. If that is present, we should mount that into the Che server and use that. For the environment variables that are involved with changing the mount location, if any of the environment variables requires a che.properties modification, take the file passed in by the user and use sed to alter the values so that the environment variables are overrides. If no che.properties exists, then we can create a new one and append the appropriate property entries. |
USAGE=" | ||
Usage: | ||
`basename "$0"` [COMMAND] | ||
start Starts Che server in new console |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Container is started as detached docker container. I'm not sure it is precise and meaningful to say that it is launched in a new console
If che container is stopped neither |
Doesn't work on my linux because of problems with permissions
|
Everything else is awesome. What a complex PR. @l0rd super cool contribution! |
} | ||
|
||
info() { | ||
printf "${GREEN}INFO:${NC} %s\n" "${1}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
multiple spaces after printf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing spaces removed
And cool improvement from @TylerJewell, good job guys! |
@l0rd @TylerJewell I'm curious how are you going to marge that PR with 30 commits? Are you going to squash it or leave these 30 commits? |
} | ||
|
||
server_is_booted() { | ||
HTTP_STATUS_CODE=$(curl -I http://"${CHE_HOST_IP}":"${CHE_PORT}"/api/ 2>/dev/null \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can also use specific options of curl instead of manual parsing of output
curl http://"${CHE_HOST_IP}":"${CHE_PORT}"/api/ -s -o /dev/null --write-out "%{http_code}"
where
-s do not print additional info
-o /dev/null suppress response body
--write-out "%{http_code}"` print status code
@garagatyi I've updated I personally don't mind leaving the 30 commits like that (authors and history are preserved) but if you thinks it's more appropriate I have no problem squashing all of them. |
@skabashnyuk @riuvshin @TylerJewell how do you think is it better to squash commits or we are ok if this goes into master with such a huge history tree? |
squash |
--squash |
…/restart Che Signed-off-by: Mario Loriedo <[email protected]>
fb38bdb
to
01ee7bc
Compare
@garagatyi @riuvshin @skabashnyuk done 😃 |
@l0rd Thanks! |
The only commit that is not signed is @TylerJewell's commit. Do I need to sign that commit with my signature? |
I believe so. This commit is pushed by you, so it doesn't prove that it is authored by @TylerJewell. |
Signed-off-by: Mario Loriedo <[email protected]>
01ee7bc
to
cdd2e5f
Compare
Done |
Thanks |
@l0rd @TylerJewell is this PR ready or other changes are still needed? |
Signed-off-by: Mario Loriedo <[email protected]>
cdd2e5f
to
61b6442
Compare
Congratulations @l0rd! |
The goal of this PR is to simplify the
docker run
command to start/stop/update/restart Che. To test it:docker build -t codenvy/che:launcher -f Dockerfile.launcher .
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock codenvy/che-launcher start
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock codenvy/che-launcher update
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock codenvy/che-launcher restart
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock codenvy/che-launcher stop