-
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
CLI - Separate debugging apart from local repo #3581
Conversation
Do not merge this until:
|
Build success. https://ci.codenvycorp.com/job/che-pullrequests-build/1497/ |
Build success. https://ci.codenvycorp.com/job/che-pullrequests-build/1498/ |
@@ -30,8 +30,8 @@ cmd_config() { | |||
fi | |||
|
|||
# Development mode |
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.
Does this comment still relevant?
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.
Good catch. Updated.
|
||
# Super weird bug - sometimes, the RM command doesn't wipe everything, so we have to repeat it a couple times | ||
until directory_is_clean; do | ||
docker_run -v "${CHE_HOST_INSTANCE}/dev":/root/dev alpine:3.4 sh -c "rm -rf /root/dev/${CHE_MINI_PRODUCT_NAME}-tomcat" > /dev/null 2>&1 || true |
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.
Why do you change path from /root/dev/* to /root/dev/${CHE_MINI_PRODUCT_NAME}-tomcat" ?
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.
I didn't make this path change. I believe that @riuvshin had made this path change in another issue that was already reviewed and merged. I believe it has to do with being clearer in the in the instance folder on what parts are Tomcat vs. which parts are not.
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.
Then can you rebase your branch or merge master into it
@@ -76,7 +82,21 @@ generate_configuration_with_puppet() { | |||
CHE_ENV_FILE="${CHE_HOST_INSTANCE}/config/$CHE_MINI_PRODUCT_NAME.env" | |||
fi | |||
|
|||
if [ "${CHE_DEVELOPMENT_MODE}" = "on" ]; then | |||
if debug_server; then | |||
DEV_MODE="development" |
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.
CHE_ENVIRONMENT looks better than DEV_MODE
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.
Updated.
-e \"CHE_ASSEMBLY=${CHE_ASSEMBLY}\" \ | ||
--entrypoint=/usr/bin/puppet \ | ||
$IMAGE_INIT \ | ||
apply --modulepath \ | ||
/etc/puppet/modules/ \ | ||
/etc/puppet/manifests/${CHE_MINI_PRODUCT_NAME}.pp --show_diff" | ||
/etc/puppet/manifests/${CHE_MINI_PRODUCT_NAME}.pp --show_diff ${WRITE_LOGS}" | ||
else |
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.
It looks like both branches of if clause are equal now, 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.
They are different. In rows 85-97, we have a different logic for what this variable will contain dependening upon whether you have activated debugging or not. So with this logic, you can now have four combinations: using a repo (yes / no) or debugging (write to logs yes / no).
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.
I have decided that the if() logic in this branch is no longer needed. So I have simplified this down to remove the if logic and generate a single command with variables.
else | ||
return 0 | ||
fi | ||
} |
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.
Please add trailing new line at the end of file
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.
Thanks
alpine:3.4 sh -c "rm -rf /root${CHE_CONTAINER_ROOT}/docs \ | ||
&& rm -rf /root${CHE_CONTAINER_ROOT}/instance \ | ||
&& rm -rf /root${CHE_CONTAINER_ROOT}/${CHE_MINI_PRODUCT_NAME}.env" > /dev/null 2>&1 || true | ||
|
||
# Super weird bug. For some reason on windows, this command has to be run 3x for everything |
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.
Does docker have an issue for that?
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.
No, I haven't created an issue. I wasn't sure it was a docker issue for it. We discovered this a couple months ago when we first implemented the cmd_destroy
function. We were seeing that we had to 3x remove stuff in that function and now it's coming up again. I can create that issue for them.
until directory_is_empty; do | ||
docker_run -v "${CHE_HOST_CONFIG}":/root${CHE_CONTAINER_ROOT} \ | ||
alpine:3.4 sh -c "rm -rf /root${CHE_CONTAINER_ROOT}/docs \ | ||
&& rm -rf /root${CHE_CONTAINER_ROOT}/instance \ |
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.
Have you checked whether multiple runs of this command is still needed when && replaced with ; ?
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.
When I put a semicolon there, then on windows it only requires a single loop to work. Nice catch!
@@ -78,3 +66,12 @@ cmd_destroy() { | |||
fi | |||
} | |||
|
|||
directory_is_empty() { |
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.
It is a bit confusing to have both directory_is_empty and directory_is_clean functions. Is it on purpose?
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.
They had different syntax of what to check. So I keep both as directory_is_empty
and then add a qualifier for the one in config now.
else | ||
return 0 | ||
fi | ||
} |
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.
Please add trailing new line at the end of file
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
afaik we wanted only possibility to enable debug for prod mode, if repo is mounted debug must be activated automatically. |
if [ "${CHE_DEVELOPMENT_MODE}" = "on" ]; then | ||
if debug_server; then | ||
DEV_MODE="development" | ||
WRITE_LOGS="" |
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.
does that mean that puppet logs will be shown only in debug mode? debug mode should only activate debug and do not change any other behaviour
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, it means that puppet logs will be streamed if you have --debug
only. If you mount a repository, but do not provide --debug
then they would not be streamed.
info "start" "Debug: ${DISPLAY_DEBUG_URL}" | ||
fi | ||
else | ||
error "(${CHE_MINI_PRODUCT_NAME} start): Timeout waiting for server. Run \"docker logs ${CHE_SERVER_CONTAINER_NAME}\" to inspect the issue." |
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.
looks like kill $LOG_PID > /dev/null 2>&1 is needed here also
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.
Moved the kill operation to be outside of hte initial loop so that it's killed first, displayed second.
-e \"CHE_CONFIG=${CHE_HOST_INSTANCE}\" \ | ||
-e \"CHE_INSTANCE=${CHE_HOST_INSTANCE}\" \ | ||
-e \"CHE_DEVELOPMENT_REPO=${CHE_HOST_DEVELOPMENT_REPO}\" \ | ||
-e \"CHE_REPO=${CHE_REPO}\" \ |
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.
Can you elaborate on why did you change CHE_HOST_DEVELOPMENT_REPO. As I can see it is still used in other places.
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.
It was just come cleanup to keep things simpler. The puppet templates had logic where both the repo and debugging logic was using the same variable. And this was needed to separate the logic across two variables.
I tried it and here is what I found:
|
I think you do not have the right images. You need to wipe everything and then rebuild /base, /init, /cli in that order. |
I rebuilt everything with build-all script |
I have never used that script - and I think we should assume that it's not perfect. Because you need to make sure that /cli image inherits from the right /base image. |
Sorry, I forgot to switch branch 😳
|
Yeah, I did the formatting on purpose. I figure in debugging mode, developers do not care about formatting. I'll respond to other comments later today. |
I believe this issue is ready for merging. Will update the matching Codenvy issue. |
Build success. https://ci.codenvycorp.com/job/che-pullrequests-build/1515/ |
What does this PR do?
This PR creates a separation of concern between the concept of using a local repository
:/repo
apart from activating development mode + debugging--debug
. In the existing CLI, these two concepts are mixed together, so that anytime you mount a local repository, debugging of the che server is activated. By separating these two concerns, a user can now activate debugging for images within the shipped Docker image. Or, a user can also use local binaries in production mode.--debug
:/repo
is mounted.:/repo
is not mounted AND--debug
is activated, then debugs binaries shipping within eclipse/che-serverCHE_DEBUG_PORT
was not being used in thedocker-compose.yml
template.--debug
displays the Che server streaming output to the foreground, and then kills it after server is booted.What issues does this PR fix or reference?
#3542
#3546
Previous behavior
If
:/repo
was mounted, then dev mode was automatically activated. But there was no way to debug internal binaries. Now the only way to activate debug mode is with--debug
added to any command. The:/repo
is now optional, only if you want to debug your source repo.Testing
To test this, there are modifications to three images - you need to rebuild
dockerfiles/base
,dockerfiles/cli
, anddockerfiles/init
. Or you can run:Codenvy Updates
The Codenvy and ARTIK CLIs now inherit from the Che CLI. This could be breaking behavior for those inherited CLIs. Things to update:
CHE_DEVELOPMENT_MODE
is no longeron
oroff
. There is now aCHE_DEBUG
which istrue
orfalse
. Rather it'sdevelopment
orproduction
. There is now adebug_server()
method which will tell you if debugging is on.You can now call
local_repo()
to find out if a local repository has been activated or not. In the puppet configuration of cmd_config(), special attention must be taken as we now have different syntax for four configurations - debug or no-debug and local repo or no-local-repo.In the puppet module for Docker compose, the debug port should be set if
CHE_DEBUG=true
. However, the local assembly should only be mounted to the container iflocal_repo() = true
. Before, the variable was meaning double - that it was for both dev mode and for using a repo. Now we have a hard separation.When this is merged, also merge:
eclipse-che/che-docs#19
codenvy/codenvy#1458