From abc861d5dbc7e2bf28e7f9c03bd8cd96da7c9d0e Mon Sep 17 00:00:00 2001 From: Karishma Joseph Date: Fri, 25 Feb 2022 13:59:18 -0800 Subject: [PATCH] Remove PA-RCA files from OS home dir Signed-off-by: Karishma Joseph --- build.gradle | 7 +++++-- pa_bin/performance-analyzer-agent | 8 ++++---- packaging/deb/postinst | 11 +++++++++-- packaging/performance-analyzer-agent-cli | 2 +- packaging/rpm/postinst | 11 +++++++++-- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index 5ae73071..602b90aa 100644 --- a/build.gradle +++ b/build.gradle @@ -424,8 +424,11 @@ bundlePlugin { into "extensions" include "performance-analyzer-agent" } - from("$rcaArtifactsDir") { - into "performance-analyzer-rca" + from("$rcaArtifactsDir/bin") { + into "rca_bin" + } + from("$rcaArtifactsDir/lib") { + into "rca_lib" } from("packaging") { include "performance-analyzer-agent-cli" diff --git a/pa_bin/performance-analyzer-agent b/pa_bin/performance-analyzer-agent index 53232766..ba8ab7de 100755 --- a/pa_bin/performance-analyzer-agent +++ b/pa_bin/performance-analyzer-agent @@ -34,12 +34,12 @@ export JAVA_HOME=$JAVA_HOME # We need to change this file: https://github.com/opensearch-project/opensearch-build/blob/main/release/docker/config/opensearch/opensearch-docker-entrypoint.sh if ! echo $* | grep -E '(^-d |-d$| -d |--daemonize$|--daemonize )' >/dev/null; then - export JAVA_OPTS=-Dopensearch.path.home=$OPENSEARCH_HOME\ -Dlog4j.configurationFile=$OPENSEARCH_HOME/performance-analyzer-rca-1.3.0-SNAPSHOT/pa_config/log4j2.xml - exec $OPENSEARCH_HOME/performance-analyzer-rca-1.3.0-SNAPSHOT/bin/performance-analyzer-rca + export JAVA_OPTS=-Dopensearch.path.home=$OPENSEARCH_HOME\ -Dlog4j.configurationFile=$OPENSEARCH_HOME/plugins/opensearch-performance-analyzer-1.3.0-SNAPSHOT/pa_config/log4j2.xml + exec $OPENSEARCH_HOME/plugins/opensearch-performance-analyzer-1.3.0-SNAPSHOT/rca_bin/performance-analyzer-rca else echo 'Starting deamon' - export JAVA_OPTS=-Dopensearch.path.home=$OPENSEARCH_HOME\ -Dlog4j.configurationFile=$OPENSEARCH_HOME/performance-analyzer-rca-1.3.0-SNAPSHOT/pa_config/log4j2.xml - exec $OPENSEARCH_HOME/performance-analyzer-rca-1.3.0-SNAPSHOT/bin/performance-analyzer-rca & + export JAVA_OPTS=-Dopensearch.path.home=$OPENSEARCH_HOME\ -Dlog4j.configurationFile=$OPENSEARCH_HOME/plugins/opensearch-performance-analyzer-1.3.0-SNAPSHOT/pa_config/log4j2.xml + exec $OPENSEARCH_HOME/plugins/opensearch-performance-analyzer-1.3.0-SNAPSHOT/rca_bin/performance-analyzer-rca & pid=$! PID_LOC=/tmp/performance-analyzer-agent diff --git a/packaging/deb/postinst b/packaging/deb/postinst index fee9b787..070de61b 100644 --- a/packaging/deb/postinst +++ b/packaging/deb/postinst @@ -7,7 +7,15 @@ if [ -z "$OPENSEARCH_HOME" ]; then fi # Prepare the RCA reader process for execution -mv "$OPENSEARCH_HOME"/plugins/opensearch-performance-analyzer/performance-analyzer-rca $OPENSEARCH_HOME +PA_PLUGIN_PATH=$OUTPUT/plugins/opensearch-performance-analyzer +RCA_LIB_PATH=$OUTPUT/plugins/opensearch-performance-analyzer/rca_lib +# Remove common lib files between PA plugin and RCA reader process +for f in `ls -1 $PA_PLUGIN_PATH`; do + if [[ $(diff $RCA_LIB_PATH/$f $PA_PLUGIN_PATH/$f | wc -c) -eq 0 ]]; then + rm -rf $RCA_LIB_PATH/$f; + fi +done; + if [ -f "$OPENSEARCH_HOME"/bin/opensearch-performance-analyzer/performance-analyzer-agent-cli ]; then mv "$OPENSEARCH_HOME"/bin/opensearch-performance-analyzer/performance-analyzer-agent-cli "$OPENSEARCH_HOME"/bin rm -rf "$OPENSEARCH_HOME"/bin/opensearch-performance-analyzer @@ -20,7 +28,6 @@ echo 'true' > /var/lib/opensearch/performance_analyzer_enabled.conf echo 'true' > /var/lib/opensearch/rca_enabled.conf chown opensearch /var/lib/opensearch/performance_analyzer_enabled.conf chown opensearch /var/lib/opensearch/rca_enabled.conf -chown -R opensearch "$OPENSEARCH_HOME/performance-analyzer-rca" chmod a+rw /tmp if ! grep -q '## OpenSearch Performance Analyzer' /etc/opensearch/jvm.options; then diff --git a/packaging/performance-analyzer-agent-cli b/packaging/performance-analyzer-agent-cli index 014b5b35..04bd53b0 100644 --- a/packaging/performance-analyzer-agent-cli +++ b/packaging/performance-analyzer-agent-cli @@ -5,7 +5,7 @@ PA_AGENT_JAVA_OPTS="-Dlog4j.configurationFile=$OPENSEARCH_HOME/plugins/opensearc -XX:MaxRAM=400m" OPENSEARCH_MAIN_CLASS="org.opensearch.performanceanalyzer.PerformanceAnalyzerApp" \ -OPENSEARCH_ADDITIONAL_CLASSPATH_DIRECTORIES=performance-analyzer-rca/lib \ +OPENSEARCH_ADDITIONAL_CLASSPATH_DIRECTORIES=plugins/opensearch-performance-analyzer/rca_lib:plugins/opensearch-performance-analyzer \ OPENSEARCH_JAVA_OPTS=$PA_AGENT_JAVA_OPTS \ exec $OPENSEARCH_HOME/bin/opensearch-cli \ "$@" diff --git a/packaging/rpm/postinst b/packaging/rpm/postinst index 2a933759..b5769eb6 100644 --- a/packaging/rpm/postinst +++ b/packaging/rpm/postinst @@ -13,7 +13,15 @@ if [ -z "$OPENSEARCH_HOME" ]; then fi # Prepare the RCA reader process for execution -mv "$OPENSEARCH_HOME"/plugins/opensearch-performance-analyzer/performance-analyzer-rca $OPENSEARCH_HOME +PA_PLUGIN_PATH=$OUTPUT/plugins/opensearch-performance-analyzer +RCA_LIB_PATH=$OUTPUT/plugins/opensearch-performance-analyzer/rca_lib +# Remove common lib files between PA plugin and RCA reader process +for f in `ls -1 $PA_PLUGIN_PATH`; do + if [[ $(diff $RCA_LIB_PATH/$f $PA_PLUGIN_PATH/$f | wc -c) -eq 0 ]]; then + rm -rf $RCA_LIB_PATH/$f; + fi +done; + if [ -f "$OPENSEARCH_HOME"/bin/opensearch-performance-analyzer/performance-analyzer-agent-cli ]; then mv "$OPENSEARCH_HOME"/bin/opensearch-performance-analyzer/performance-analyzer-agent-cli "$OPENSEARCH_HOME"/bin rm -rf "$OPENSEARCH_HOME"/bin/opensearch-performance-analyzer @@ -26,7 +34,6 @@ echo 'true' > /var/lib/opensearch/performance_analyzer_enabled.conf echo 'true' > /var/lib/opensearch/rca_enabled.conf chown opensearch /var/lib/opensearch/performance_analyzer_enabled.conf chown opensearch /var/lib/opensearch/rca_enabled.conf -chown -R opensearch "$OPENSEARCH_HOME/performance-analyzer-rca" chmod a+rw /tmp if ! grep -q '## OpenSearch Performance Analyzer' /etc/opensearch/jvm.options; then