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

Simplify Tomcat che.sh bootsrap script #2786

Merged
merged 1 commit into from
Oct 27, 2016
Merged

Conversation

TylerJewell
Copy link

@TylerJewell TylerJewell commented Oct 14, 2016

What does this PR do?

Contains a rewrite for the native Tomcat scripts for starting and stopping Che to incorporate a number of improvements requested by users, and to remove a number of Docker-launch capabilities that are no longer needed as we provide che-server and che-launcher containers, which are more commonly used.

The improvements targeted for this pull request:

  • Get rid of all --<command> command line options and replace them with environment variables.
  • Move any bootstrap code that is specific to a container into che-server container.
  • Improve the che-server container to handle container-specific logic, such as che-lib.
  • Simplify the che-server container to only require a single /data mount folder.
  • Make improvements to che-launcher container to adapt to these improvements. Located in che-dockerfiles.
  • Support SIGTERM and SIGINT signals, so that docker stop che handled proper shutdown.

In order to deliver on this capability, we now have the Dockerfile entrypoint be start.sh which is then responsible for calling /home/user/che/bin/che.sh with the right command. We launch the command in the background which is necessary for JVM programs to receive a SIGTERM. This will also allow us to intercept the CHE_ASSEMBLY and handle the logic there along with some nice checking of the path to see if the path is valid for usage.

As part of this change, we are now only supporting a single volume mount of /data. Everything that is user configurable and / or needs to be saved in between multiple runs is now saved in this directory and volume mounted. In the basic tests - the following worked. We do an inspection in the che-server container to find the host volume that is mounted to /data. We then take that value and update the default che.properties to replace five fields with this location.

docker run -p 8080:8080 --name che --rm -v /var/run/docker.sock:/var/run/docker.sock -v /C/tmp:/data codenvy/che-server:nightly

# Fields modified in che.properties by the startup script to write in the proper /data location:
che.workspace.storage=${CHE_DATA_HOST}/workspaces
che.conf.storage=/data/storage
machine.server.ext.archive=${CHE_DATA_HOST}/lib/ws-agent.tar.gz
machine.server.terminal.path_to_archive.linux_amd64=${CHE_DATA_HOST}/lib/linux_amd64/terminal
machine.server.terminal.path_to_archive.linux_arm7=${CHE_DATA_HOST}/lib/linux_arm7/terminal
# where CHE_DATA_HOST is derived as the volume mount of /data inside the container

Shadow documentation:
https://eclipse-che.readme.io/v5.0/docs/usage-docker-server-1

Build

This image is not yet hosted on Docker Hub. You need to build it locally.

git clone http://github.com/eclipse/che
cd che
git checkout che-startup-tcomat
cd assembly/assembly-main
mvn clean install
cd ../..
docker build -t codenvy/che-server:nightly .

What issues does this PR fix or reference?

#2754 (open) - che.sh not checking for /var/run/docker.sock, & do DOCKER_HOST checks.
#2755 (open) - Usability improvements to che-server execution
#2771 - mapping

Previous behavior

The existing native script has a mix of environment variables and command line options which are not consistently applied. Also, the current bootstrap script will attempt to launch Docker using docker-machine if it is not present. This is no longer required as the only users of the Tomcat bootstrap script are those that understand how to configure Docker properly.

New behavior

*1. Have the trap shut down che
*2. Remove -v, -m, -a options.
*3. Remove launch_docker_vm from che.sh?
*4. Remove print_client_connect method
*5. Convert all parameters to inherit from env variables & CHE_ values
*6. Add check for any parameters with nice output for codenvy/che-server run
*7. -p:port ==> CHE_PORT
*8. -l:level ==> CHE_LOG_LEVEL (check CLI version)
*9. Show help if no parameters
*9. -r:ip ==> CHE_IP environment variable
*10. Check che-launcher for how debug is handled
*11. Add CHE_BLOCKING_ENTROPY
*12. Add CHE_LAUNCH_DOCKER_REGISTRY
*13. Add CHE_SKIP_JAVA_VERSION_CHECK
*14. Add CHE_SKIP_DOCKER_UID_ENFORCEMENT
*15. Remove USE_DOCKER, add check into early compatibility check
*16. Remove CHE_DOCKER_TAG
*17. Move help to better section - it's in the core body now
*18. Formalize CHE_SERVER_ACTION
*19. Add CHE_IN_CONTAINER=true to replace COPY_LIB
*20. Remove unnecessary Windows command output
*22. Auto detect if the container is in a VM and set necessary properties including
CHE_DOCKER_MACHINE_HOST_EXTERNAL=${HOSTNAME}
CHE_WORKSPACE_STORAGE="${CHE_DATA_HOST}/workspaces"
CHE_WORKSPACE_STORAGE_CREATE_FOLDERS=false

    1. Rename CHE_LOCAL_BINARY to just simply CHE_ASSEMBLY
    1. Refactor certain che-launcher commands to make use of CHE_HOST value instead of --remote property.

@TylerJewell TylerJewell added kind/enhancement A feature request - must adhere to the feature request template. status/in-progress This issue has been taken by an engineer and is under active development. team/pm labels Oct 14, 2016
@TylerJewell TylerJewell self-assigned this Oct 14, 2016
@codenvy-ci
Copy link

Build # 704 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/704/ to view the results.

@codenvy-ci
Copy link

Build # 705 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/705/ to view the results.

@codenvy-ci
Copy link

Build # 706 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/706/ to view the results.

@codenvy-ci
Copy link

Build # 707 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/707/ to view the results.

@codenvy-ci
Copy link

Build # 708 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/708/ to view the results.

@codenvy-ci
Copy link

Build # 709 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/709/ to view the results.

@codenvy-ci
Copy link

Build # 710 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/710/ to view the results.

@codenvy-ci
Copy link

Build # 711 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/711/ to view the results.

ENTRYPOINT [ "/home/user/che/bin/che.sh", "-c" ]

CMD [ "run" ]
ENTRYPOINT ["/home/user/che/bin/start.sh"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing EOL

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

# Short circuit
JUMP_TO_END=false
determine_os () {
# Set OS. Mac & Windows require VirtualBox and docker-machine.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mac And windows could use as well docker 4 mac, docker 4 windows ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a bad comment - leftover. Removed it.

@@ -83,6 +83,17 @@
</dependencies>
<build>
<plugins>
<plugin>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can get rid of this plugin definition by adding a newline in start.sh script after the header

#
<--insert newline there
pid=0

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good catch - that explains the issue.

error_exit "This Linux user is not in 'docker' group. `
`See https://docs.docker.com/engine/installation/ubuntulinux/#create-a-docker-group"
error "This Linux user is not in 'docker' group. `
`See https://docs.docker.com/engine/installation/ubuntulinux/#create-a-docker-group"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire check was removed - as we no longer need to perform these checks.

# if [ "${CHE_IN_CONTAINER}" == "true" ]; then

# Make sure the user named "user" is the owner of the CHE_HOME directory.
# Make sure the user named "user" is the owner of the CHE_DATA directory.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe say CHE_HOME and CHE_DATA directories instead of 2 lines

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is removed in che.sh and it's been added into docker.sh with an improved message.

@@ -0,0 +1,235 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need bash ? or sh should be enough ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, correct - downgraded it to sh

Copy link
Contributor

@benoitf benoitf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested on ubuntu box and it worked fine

On Mac I wasn't able to run native che with docker4mac but it is already the case now, so :-)

@codenvy-ci
Copy link

Build # 715 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/715/ to view the results.

@TylerJewell TylerJewell changed the title WIP: :Simplify Tomcat che.sh bootsrap script Simplify Tomcat che.sh bootsrap script Oct 19, 2016
launch_docker_registry
execute_che () {
check_docker
determine_os
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check_doker and determine_os won't work when running in a non privileged container on Kubernetes or OpenShift

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will have to manage that in another PR, I believe. The scope of the current scirpt is related to the assumption that you are running the container on a host without privileged mode and /var/run/docker.sock activated.

We have two scenarios that we have to address with the che-server container, and the underlying che.sh Tomcat script:
1: - if it is a non-privileged container, then we need to rewrite certain functions - or pass in environment values from the container orchestrator.
2: - we have customers that are going to require Che in localhost mode - without the use of any Docker capabilities. This will need to come a bit later this year. But we make a large number of assumptions about Docker in the current scripts which would not be necessary and must be removed as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I see your point: some customers still need to run che-server in localhost mode, without Docker, and they deserve a "launcher" too. And I completely agree. But why not expanding the launcher itself to support this scenario? Or a new no-docker-launcher script that would reuse launcher_funcs.sh.

Current PR has a couple of drawbacks:

  • Code duplication (launcher already does a lot of these checks)
  • Incompatibility with kubernetes/openshift

And I'm for a complete rewrite of che.sh to remove all the checks that are already handled by the launcher(s).

@TylerJewell
Copy link
Author

I agree with some of these points but not all of them. I will get time this week to articulate better the separation of concerns.

I don't think the goal is necessarily avoidance of duplication. However I think the separation of concerns has to be driven by the desired customer use case and we should better articulate the purpose of each entry point.

@bmicklea bmicklea added this to the 5.0.0-M7 milestone Oct 25, 2016
@bmicklea
Copy link

@skabashnyuk please plan to have this merged early in M7

@mkuznyetsov mkuznyetsov merged commit e3670d5 into master Oct 27, 2016
@mkuznyetsov mkuznyetsov deleted the che-startup-tcomat branch October 27, 2016 14:42
@bmicklea bmicklea mentioned this pull request Nov 16, 2016
66 tasks
JPinkney pushed a commit to JPinkney/che that referenced this pull request Aug 17, 2017
Simplify Tomcat che.sh bootsrap script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement A feature request - must adhere to the feature request template. status/in-progress This issue has been taken by an engineer and is under active development.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants