From 5dcbfee7902c90f534431117f228a053e53e5729 Mon Sep 17 00:00:00 2001 From: Elbakyan Shirak Date: Thu, 25 Apr 2024 11:49:24 +0400 Subject: [PATCH] Fix bug 67631 - truncate opensearch indexes after app update (#222) --- install/common/product-configuration | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/install/common/product-configuration b/install/common/product-configuration index bee9724370..2dcccb747d 100644 --- a/install/common/product-configuration +++ b/install/common/product-configuration @@ -627,12 +627,6 @@ change_elasticsearch_config(){ systemctl stop opensearch systemctl is-active --quiet elasticsearch && systemctl stop elasticsearch - ELASTIC_VERSION=$(awk '/build:/{f=1} f&&/version:/{gsub(/"/,"",$2);print $2; exit}' /usr/share/opensearch/manifest.yml 2>/dev/null || echo "2.11.1") - [[ -f "$APP_DIR/.private/opensearch-version" && $(cat $APP_DIR/.private/opensearch-version) != *$ELASTIC_VERSION* ]] && $MYSQL "$DB_NAME" -e "TRUNCATE webstudio_index"; - - echo "$ELASTIC_VERSION" > $APP_DIR/.private/opensearch-version - chmod o-rwx $APP_DIR/.private/opensearch-version - sed -i '/^plugins\.security/d' /etc/opensearch/opensearch.yml sed -i '/CN=kirk,OU=client,O=client,L=test, C=de/d' /etc/opensearch/opensearch.yml if /usr/share/opensearch/bin/opensearch-plugin list | grep -x "opensearch-security" > /dev/null 2>&1 ; then @@ -907,3 +901,11 @@ elif $PACKAGE_MANAGER rabbitmq-server >/dev/null 2>&1; then fi restart_services + +# Truncate MySQL DB to make opensearch work with updated app. Strictly after restart_services () +if $PACKAGE_MANAGER opensearch >/dev/null 2>&1; then + ELASTIC_VERSION=$(awk '/build:/{f=1} f&&/version:/{gsub(/"/,"",$2);print $2; exit}' /usr/share/opensearch/manifest.yml 2>/dev/null || echo "2.11.1") + [[ ! -f "$APP_DIR/.private/opensearch-version" || $(cat "$APP_DIR/.private/opensearch-version") != *"$ELASTIC_VERSION"* ]] && $MYSQL "$DB_NAME" -e "TRUNCATE webstudio_index"; + echo "$ELASTIC_VERSION" > $APP_DIR/.private/opensearch-version + chmod o-rwx $APP_DIR/.private/opensearch-version +fi