Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 4 additions & 32 deletions _functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ Environment Variables

DEPLOYMENT_SFTP_ENABLED : Do you need to configure exo-lecko addon
DEPLOYMENT_ES_EMBEDDED_MIGRATION_ENABLED : Enable elastic serach migration from embedded to standalone
DEPLOYMENT_ES7_MIGRATION_ENABLED : Enable elastic serach migration to version 7
DEPLOYMENT_ES_MIGRATION_ENABLED : Enable elasticserach migration
DEPLOYMENT_ES_INTERMEDIATE_UPGRADE_VERSIONS : elasticseach intermediate versions used in migration
DEPLOYMENT_GZIP_ENABLED : Enable Gzip Compression on the Tomcat Server
DEPLOYMENT_LOGBACK_LOGGERS : Enable Debug logging for java packages (comma seperated eg: org.exoplatform:DEBUG,org.hibernate,org.springframework:ERROR), Default logging level is DEBUG
DEPLOYMENT_UPLOAD_MAX_FILE_SIZE : Configure the max size for file upload in eXo (in MB)
Expand Down Expand Up @@ -925,7 +926,7 @@ initialize_product_settings() {
if [[ "${PRODUCT_VERSION}" =~ ^(7.3) ]]; then
env_var "DEPLOYMENT_FORCE_JDBC_DRIVER_ADDON" "true"
env_var "DEPLOYMENT_ES_IMAGE" "elasticsearch"
env_var "DEPLOYMENT_ES_IMAGE_VERSION" "8.18.8"
env_var "DEPLOYMENT_ES_IMAGE_VERSION" "9.4.5"
env_var "DEPLOYMENT_MYSQL_DEFAULT_VERSION" "8.4.11" # Default version of the mysql server to use
env_var "DEPLOYMENT_POSTGRESQL_DEFAULT_VERSION" "17" # Default version of the postgresql server to use
env_var "DEPLOYMENT_MYSQL_ADDON_VERSION" "2.3.0" # Default version of the mysql driver addon to use
Expand Down Expand Up @@ -1144,7 +1145,7 @@ initialize_product_settings() {
configurable_env_var "DEPLOYMENT_JITSI_CALL_IMAGE_VERSION" "latest"
elif [[ "${PRODUCT_VERSION}" =~ ^(7.3) ]]; then
env_var "DEPLOYMENT_ES_IMAGE" "elasticsearch"
env_var "DEPLOYMENT_ES_IMAGE_VERSION" "8.18.8"
env_var "DEPLOYMENT_ES_IMAGE_VERSION" "9.4.5"

env_var "DEPLOYMENT_MYSQL_ADDON_VERSION" "2.3.0" # Default version of the mysql driver addon to use
env_var "DEPLOYMENT_POSTGRESQL_ADDON_VERSION" "2.5.4" # Default version of the jdbc postgresql driver addon to use
Expand Down Expand Up @@ -2461,35 +2462,6 @@ do_start() {
if ${DEPLOYMENT_DEV_ENABLED:-false} ; then
echo_info "DEV Mode is enabled."
fi

if ${DEPLOYMENT_ES_EMBEDDED_MIGRATION_ENABLED:-false}; then
echo_info "Elasticsearch Embedded to Standalone migration is successfully done. Please remove DEPLOYMENT_ES_EMBEDDED_MIGRATION_ENABLED property!"
fi
if ${DEPLOYMENT_ES7_MIGRATION_ENABLED:-false}; then
# Anyway no way to handle the error case. hard luck! We remove container ES5 anyway
END_MIGRATION_ES_MSG_ERROR="Elasticsearch upgrade failed due to previous errors"
END_MIGRATION_ES_MSG_SUCCESS="Elasticsearch upgrade proceeded successfully"
# Check for the end of ES migration
set +e
while [ true ];
do
if grep -q "${END_MIGRATION_ES_MSG_ERROR}" "${DEPLOYMENT_LOG_PATH}" || grep -q "${END_MIGRATION_ES_MSG_SUCCESS}" "${DEPLOYMENT_LOG_PATH}"; then
break
fi
sleep 1
done
set -e
echo_info "ES7 Upgrade is finished. Cleaning up ES5..."
do_drop_es_old
echo_info "Cleanup finished!"
if grep -q "${END_MIGRATION_ES_MSG_ERROR}" "${DEPLOYMENT_LOG_PATH}"; then
echo_warn "Elasticsearch 7 Migration is done with errors. This operation cannot be repeated! Please remove DEPLOYMENT_ES7_MIGRATION_ENABLED property!"
elif grep -q "${END_MIGRATION_ES_MSG_SUCCESS}" "${DEPLOYMENT_LOG_PATH}"; then
echo_info "Elasticsearch 7 Migration is successfully done. Please remove DEPLOYMENT_ES7_MIGRATION_ENABLED property!"
fi
fi


)
}

Expand Down
151 changes: 78 additions & 73 deletions _functions_es.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ do_start_es() {
if ${DEPLOYMENT_ES_EMBEDDED_MIGRATION_ENABLED:-false}; then
do_migrate_embedded
fi
if ${DEPLOYMENT_ES7_MIGRATION_ENABLED:-false}; then
if ${DEPLOYMENT_ES_MIGRATION_ENABLED:-false}; then
do_upgrade
fi
fi
Expand All @@ -83,48 +83,7 @@ do_start_es() {

# Ensure there is no container with the same name
delete_docker_container ${DEPLOYMENT_ES_CONTAINER_NAME}

if [[ ! "${DEPLOYMENT_ES_IMAGE_VERSION}" =~ ^1.[0-9.]+$ ]]; then
if ${DEPLOYMENT_ES7_MIGRATION_ENABLED:-false}; then
# Need to get the docker internal ip address of the container to ensure ES trust mechanism works fine.
env_var DEPLOYMENT_ES_OLD_INTERNAL_ADDR $(${DOCKER_CMD} inspect --format '{{ .NetworkSettings.IPAddress }}' ${DEPLOYMENT_ES_CONTAINER_NAME}_old)
${DOCKER_CMD} run \
-d \
-p "127.0.0.1:${DEPLOYMENT_ES_HTTP_PORT}:9200" \
-v ${DEPLOYMENT_ES_CONTAINER_NAME}:/usr/share/elasticsearch/data \
-e ES_JAVA_OPTS="-Xms${DEPLOYMENT_ES_HEAP} -Xmx${DEPLOYMENT_ES_HEAP}" \
-e "node.name=${INSTANCE_KEY}" \
-e "cluster.name=${INSTANCE_KEY}" \
-e "cluster.initial_master_nodes=${INSTANCE_KEY}" \
-e "xpack.security.enabled=false" \
-e "network.host=_site_" \
-e "reindex.remote.whitelist=${DEPLOYMENT_ES_OLD_INTERNAL_ADDR}:9200" \
-h 'search' \
--health-cmd='curl --silent --fail search:9200/_cluster/health || exit 1' \
--health-interval=30s \
--health-timeout=30s \
--health-retries=3 \
--name ${DEPLOYMENT_ES_CONTAINER_NAME} ${DEPLOYMENT_ES_IMAGE}:${DEPLOYMENT_ES_IMAGE_VERSION}
else
${DOCKER_CMD} run \
-d \
-p "127.0.0.1:${DEPLOYMENT_ES_HTTP_PORT}:9200" \
-v ${DEPLOYMENT_ES_CONTAINER_NAME}:/usr/share/elasticsearch/data \
-e ES_JAVA_OPTS="-Xms${DEPLOYMENT_ES_HEAP} -Xmx${DEPLOYMENT_ES_HEAP}" \
-e "node.name=${INSTANCE_KEY}" \
-e "cluster.name=${INSTANCE_KEY}" \
-e "cluster.initial_master_nodes=${INSTANCE_KEY}" \
-e "xpack.security.enabled=false" \
-e "network.host=_site_" \
-h 'search' \
--health-cmd='curl --silent --fail search:9200/_cluster/health || exit 1' \
--health-interval=30s \
--health-timeout=30s \
--health-retries=3 \
--name ${DEPLOYMENT_ES_CONTAINER_NAME} ${DEPLOYMENT_ES_IMAGE}:${DEPLOYMENT_ES_IMAGE_VERSION}
fi
else
${DOCKER_CMD} run \
${DOCKER_CMD} run \
-d \
-p "127.0.0.1:${DEPLOYMENT_ES_HTTP_PORT}:9200" \
-v ${DEPLOYMENT_ES_CONTAINER_NAME}:/usr/share/elasticsearch/data \
Expand All @@ -139,10 +98,8 @@ do_start_es() {
--health-timeout=30s \
--health-retries=3 \
--name ${DEPLOYMENT_ES_CONTAINER_NAME} ${DEPLOYMENT_ES_IMAGE}:${DEPLOYMENT_ES_IMAGE_VERSION}
fi

echo_info "${DEPLOYMENT_ES_CONTAINER_NAME} container started"

check_es_availability
}

Expand Down Expand Up @@ -207,37 +164,85 @@ do_migrate_embedded() {
# Perform Elasticsearch Upgrade
do_upgrade(){
case true in
${DEPLOYMENT_ES7_MIGRATION_ENABLED:-false})
echo_info "Elasticsearch migration to version 7 is enabled! Starting..."
echo_warn "Please remove DEPLOYMENT_ES7_MIGRATION_ENABLED when the migration is done."
echo_info "Starting old ES..."

ensure_docker_container_stopped ${DEPLOYMENT_ES_CONTAINER_NAME}_old
delete_docker_container ${DEPLOYMENT_ES_CONTAINER_NAME}_old

local mount_point=$(${DOCKER_CMD} volume inspect --format '{{ .Mountpoint }}' ${DEPLOYMENT_ES_CONTAINER_NAME}) || return 0
[ -z "${mount_point:-}" ] && return 0
sudo mv -v ${mount_point} ${mount_point}_old
sudo chown 1000.1000 -R ${mount_point}_old
${DEPLOYMENT_ES_MIGRATION_ENABLED:-false})
echo_info "Ensure that deployed ES container is dropped"
set +e
${DOCKER_CMD} rm -v ${DEPLOYMENT_ES_CONTAINER_NAME} 2>/dev/null
set -e
echo_info "Elasticsearch migration to version is enabled! Starting..."
echo_warn "Please remove DEPLOYMENT_ES_MIGRATION_ENABLED when the migration is done."
echo_info "Checking for intermediate elasticsearch upgrades"
if [ -z "${DEPLOYMENT_ES_INTERMEDIATE_UPGRADE_VERSIONS:-}" ]; then
echo_info "No intermediate upgrade is required. Skipped!"
return 0
fi
echo_info "Starting intermediate Upgrades"
local mount_point=$(${DOCKER_CMD} volume inspect --format '{{ .Mountpoint }}' ${DEPLOYMENT_ES_CONTAINER_NAME}) || return 0
[ -z "${mount_point:-}" ] && return 0
sudo cp -rf ${mount_point} ${mount_point}_old
for elasticsearch_version in ${DEPLOYMENT_ES_INTERMEDIATE_UPGRADE_VERSIONS}; do
echo_info "Starting elasticsearch migration to ${elasticsearch_version}"
${DOCKER_CMD} run \
-d \
-p "127.0.0.1:${DEPLOYMENT_ES_OLD_HTTP_PORT}:9200" \
-v ${mount_point}_old:/usr/share/elasticsearch/data \
-e ES_JAVA_OPTS="-Xms${DEPLOYMENT_ES_HEAP} -Xmx${DEPLOYMENT_ES_HEAP}" \
-e "node.name=${INSTANCE_KEY}" \
-e "cluster.name=${INSTANCE_KEY}" \
-h 'search-old' \
--health-cmd='curl --silent --fail search-old:9200/_cluster/health || exit 1' \
--health-interval=30s \
--health-timeout=30s \
--health-retries=3 \
--name ${DEPLOYMENT_ES_CONTAINER_NAME}_old ${DEPLOYMENT_ES_IMAGE}:1.2.2 # FIXME VARIABLIZE IT
-d \
-p "127.0.0.1:${DEPLOYMENT_ES_HTTP_PORT}:9200" \
-v ${mount_point}:/usr/share/elasticsearch/data \
-e ES_JAVA_OPTS="-Xms${DEPLOYMENT_ES_HEAP} -Xmx${DEPLOYMENT_ES_HEAP}" \
-e "node.name=${INSTANCE_KEY}" \
-e "cluster.name=${INSTANCE_KEY}" \
-e cluster.initial_master_nodes="${INSTANCE_KEY}" \
-e network.host=_site_ \
-e xpack.security.enabled=false \
-h 'search-intermediate' \
--health-cmd='curl --silent --fail search-intermediate:9200/_cluster/health || exit 1' \
--health-interval=30s \
--health-timeout=30s \
--health-retries=3 \
--name ${DEPLOYMENT_ES_CONTAINER_NAME} ${DEPLOYMENT_ES_IMAGE}:${elasticsearch_version}
check_es_availability ${DEPLOYMENT_ES_HTTP_PORT}
if [[ "${elasticsearch_version}" == 8* ]]; then
echo_info "check for obsolete analytics indices"
set +e
indices_to_delete=$(curl -s "127.0.0.1:${DEPLOYMENT_ES_HTTP_PORT}/_settings?include_defaults=true" |
jq -r 'to_entries[]
| select(.value.settings.index.version.created | tonumber < 8000000)
| .key' | grep 'analytics')
set -e
if [[ -n "${indices_to_delete}" ]]; then
echo_info "the following analytics es indices will be deleted: ${indices_to_delete}"
while IFS= read -r index; do
[ -z "${index}" ] && continue
log "deleting index: ${index}"
curl -sS -X DELETE "127.0.0.1:${DEPLOYMENT_ES_HTTP_PORT}/${index}"
done <<< "$indices_to_delete"
echo_info "obsolete analytics indices deleting done"
fi
fi
set +e
local retry=0
local maxretries=300
echo_info "upgrade system features"
until [ "${retry}" -gt "${maxretries}" ]; do
if curl -X POST "127.0.0.1:${DEPLOYMENT_ES_HTTP_PORT}/_migration/system_features" |
jq -e '.reason == "No system indices require migration" or ( .features[] | select(.feature_name == "geoip") | .migration_status == "NO_MIGRATION_NEEDED")' >/dev/null; then
break
fi

check_es_availability ${DEPLOYMENT_ES_OLD_HTTP_PORT}
do_drop_es_data
do_create_es
sleep 1
((retry++))
done
if [ "$retry" -gt "$maxretries" ]; then
echo_warn "ERROR: geoip system feature migration did not complete after $maxretries retries"
fi
set -e
echo_info "upgrade system features done"
echo_info "Dropping container elasticsearch:${elasticsearch_version}..."
${DOCKER_CMD} stop ${DEPLOYMENT_ES_CONTAINER_NAME}
${DOCKER_CMD} rm ${DEPLOYMENT_ES_CONTAINER_NAME}
echo_info "Finished data upgrade with elasticsearch:${elasticsearch_version}."
done
sudo rm -rf ${mount_point}_old
;;
# Maybe other upgrades to be defined here.
# Maybe other upgrades to be defined here.
esac
}

Expand Down