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

Fix Che using different database path in different versions #8073

Merged
merged 16 commits into from
Jan 15, 2018

Conversation

mkuznyetsov
Copy link
Contributor

@mkuznyetsov mkuznyetsov commented Dec 27, 2017

What does this PR do?

Export Che environment variables only if there were not defined
Move database files, that were stored in different paths until and after Che 6.0.0-M3 version:

  • Database will be stored at path "/data/storage/db/che.mv.db"

  • If there is a database at old path present ("data/db/che.mv.db"), a warning will be shown in Che container logs, and, if no database is present by the new path, it will be moved there

What issues does this PR fix or reference?

should fix #8068

Fix Che using different database path in different versions.
entypoint.sh will not overwrite Che environment variables, if they were already defined

Release Notes

Docs PR

N/A

@mkuznyetsov mkuznyetsov added the kind/bug Outline of a bug - must adhere to the bug report template. label Dec 27, 2017
@mkuznyetsov mkuznyetsov self-assigned this Dec 27, 2017
@benoitf benoitf added the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Dec 27, 2017
Copy link
Contributor

@riuvshin riuvshin left a comment

Choose a reason for hiding this comment

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

please read comments, we need to handle ONLY vars that set value, vars like

export VAR=${VAR:-${DEFAULT_VAR}}

are OK as they already pick vars from ENV

@@ -47,10 +47,10 @@ Variables:

# Must be exported as this will be needed by Tomcat's JVM
DEFAULT_CHE_REGISTRY_HOST=localhost
export CHE_REGISTRY_HOST=${CHE_REGISTRY_HOST:-${DEFAULT_CHE_REGISTRY_HOST}}
Copy link
Contributor

Choose a reason for hiding this comment

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

in that case we don;t need any change because it already pick value fom ENV VAR


DEFAULT_CHE_PORT=8080
export CHE_PORT=${CHE_PORT:-${DEFAULT_CHE_PORT}}
Copy link
Contributor

Choose a reason for hiding this comment

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

in that case we don;t need any change because it already pick value fom ENV VAR

@@ -59,7 +59,7 @@ Variables:
CHE_LOG_LEVEL=${CHE_LOG_LEVEL:-${DEFAULT_CHE_LOG_LEVEL}}

DEFAULT_CHE_LOGS_DIR="${CATALINA_HOME}/logs/"
export CHE_LOGS_DIR=${CHE_LOGS_DIR:-${DEFAULT_CHE_LOGS_DIR}}
Copy link
Contributor

Choose a reason for hiding this comment

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

in that case we don;t need any change because it already pick value fom ENV VAR

CHE_DATA_HOST=$(get_che_data_from_host)

CHE_USER=${CHE_USER:-root}
export CHE_USER=$CHE_USER
[ -z "$CHE_USER" ] && export CHE_USER=$CHE_USER
Copy link
Contributor

Choose a reason for hiding this comment

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

why you changed that?

if [ "$CHE_USER" != "root" ]; then
if [ ! $(getent group docker) ]; then
echo "!!!"
echo "!!! Error: The docker group doesn't exist."
echo "!!!"
exit 1
fi
export CHE_USER_ID=${CHE_USER}
[ -z "$CHE_USER_ID" ] && export CHE_USER_ID=${CHE_USER}
Copy link
Contributor

Choose a reason for hiding this comment

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

why you changed that?


# CHE_DOCKER_IP_EXTERNAL must be set if you are in a VM.
HOSTNAME=${CHE_DOCKER_IP_EXTERNAL:-$(get_docker_external_hostname)}
if has_external_hostname; then
# Internal property used by Che to set hostname.
export CHE_DOCKER_IP_EXTERNAL=${HOSTNAME}
[ -z "$CHE_DOCKER_IP_EXTERNAL" ] && export CHE_DOCKER_IP_EXTERNAL=${HOSTNAME}
Copy link
Contributor

Choose a reason for hiding this comment

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

why you changed that?

@mkuznyetsov mkuznyetsov changed the title export Che environment variables in entrypoint.sh only if they were not already defined Fix Che using different database path in different versions Jan 9, 2018
echo "See issue https://github.com/eclipse/che/issues/8068 for details"
#in case if there is existing database in old path, back it up
if [ -f ${CHE_DATA}/db/che.mv.db ]; then
mv ${CHE_DATA}/db/che.mv.db ${CHE_DATA}/db/che.mv.db.old
Copy link
Member

Choose a reason for hiding this comment

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

It can be useful to add logs that old database is backed up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@@ -11,7 +11,7 @@

### CHE SERVER
# Folder where Che will store internal data objects
che.database=${che.home}/storage
che.database=${che.home}
Copy link
Contributor

Choose a reason for hiding this comment

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

why it's not anymore in a subfolder ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was like so in Che instances, that were running through CLI for a long while because of this che.env.erb:
https://github.com/eclipse/che/blob/56866159228bf4ba1d3b7fc8d2206c60b129579b/dockerfiles/init/modules/che/templates/che.env.erb#L36
So, the values from the che.properties or entrypoint.sh, which would point to path with "storage" directory had no effect, until recently (which was the issue cause)

I decided to consolidate everything by old path, though if you think extra "storage" directory is better, it can be changed to that

Copy link
Contributor

Choose a reason for hiding this comment

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

I would say that it looks odd to have a "root" directory as path for che database so yes using a subfolder would be better IMHO

https://github.com/eclipse/che/blob/93b974d1e0ec7836635f3d7da196b7651da8ad1b/dockerfiles/che/entrypoint.sh#L233

Copy link
Contributor

Choose a reason for hiding this comment

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

@benoitf Am I understand you correctly. You want to change db file location.
Add extra path "storage" to what we have in Che5?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes. From what I see there is a 'db' subfolder added
It's not directly stored inside the che.home folder

@mkuznyetsov
Copy link
Contributor Author

@benoitf I changed the PR, and updated the description, describing how it works now

  • database will be stored by path "/data/storage/db/che.mv.db"
  • if upgrading Che from versions, that were using different path, it will leave a warning in the container logs, and would place it in the proper path, unless there is already DB there.

@@ -84,7 +84,7 @@ set_environment_variables () {
# CHE_DOCKER_IP is used internally by Che to set its IP address
if [[ -z "${CHE_DOCKER_IP}" ]]; then
if [[ -n "${CHE_IP}" ]]; then
export CHE_DOCKER_IP="${CHE_IP}"
export CHE_DOCKER_IP="${CHE_IP}"
Copy link
Contributor

@benoitf benoitf Jan 10, 2018

Choose a reason for hiding this comment

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

maybe you can skip this change from this PR's commit as it's unrelated (it's more a indent fix)

@mkuznyetsov mkuznyetsov merged commit 3d7f1a1 into master Jan 15, 2018
@mkuznyetsov mkuznyetsov deleted the fix-entrypoint branch January 15, 2018 08:02
@benoitf benoitf removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Jan 15, 2018
@benoitf benoitf added this to the 6.0.0-M5 milestone Jan 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Outline of a bug - must adhere to the bug report template.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Che cannot access old database after it's upgrade
5 participants