Skip to content

Commit

Permalink
Merge from main, fix rpm build (#174)
Browse files Browse the repository at this point in the history
* Update configFilePath location (#172)

Signed-off-by: sruti1312 <srutiparthiban@gmail.com>

* Disable plugin if configFilePath is not present

Signed-off-by: sruti1312 <srutiparthiban@gmail.com>
  • Loading branch information
sruti1312 authored Apr 28, 2022
1 parent 4d37bd3 commit 8a39c12
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 20 deletions.
11 changes: 9 additions & 2 deletions bin/performance-analyzer-agent
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,19 @@ fi
echo "Using JAVA_HOME: $JAVA_HOME"
export JAVA_HOME=$JAVA_HOME

if [[ -z "$OPENSEARCH_PATH_CONF" ]]; then
echo "OPENSEARCH_PATH_CONF needs to be set."
exit 1
fi

echo "Using OPENSEARCH_PATH_CONF: $OPENSEARCH_PATH_CONF"

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/config/log4j2.xml\ -XX:+ExitOnOutOfMemoryError
export JAVA_OPTS=-Dopensearch.path.home=$OPENSEARCH_HOME\ -Dopensearch.path.conf=$OPENSEARCH_PATH_CONF\ -Dlog4j.configurationFile=$OPENSEARCH_HOME/performance-analyzer-rca/config/log4j2.xml\ -XX:+ExitOnOutOfMemoryError
exec $OPENSEARCH_HOME/performance-analyzer-rca/bin/performance-analyzer-rca
else
echo 'Starting deamon'
export JAVA_OPTS=-Dopensearch.path.home=$OPENSEARCH_HOME\ -Dlog4j.configurationFile=$OPENSEARCH_HOME/performance-analyzer-rca/config/log4j2.xml\ -XX:+ExitOnOutOfMemoryError
export JAVA_OPTS=-Dopensearch.path.home=$OPENSEARCH_HOME\ -Dopensearch.path.conf=$OPENSEARCH_PATH_CONF\ -Dlog4j.configurationFile=$OPENSEARCH_HOME/performance-analyzer-rca/config/log4j2.xml\ -XX:+ExitOnOutOfMemoryError
exec $OPENSEARCH_HOME/performance-analyzer-rca/bin/performance-analyzer-rca &

pid=$!
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ RUN yum update -y && \
COPY CENTOS_LICENSING.txt /root
COPY --from=prep_open_search_files --chown=1000:0 /opt/jdk-11.0.1 /opt/jdk-11.0.1
ENV OPENSEARCH_JAVA_HOME /opt/jdk-11.0.1
ENV OPENSEARCH_PATH_CONF /usr/share/opensearch/config

# Replace OpenJDK's built-in CA certificate keystore with the one from the OS
# vendor. The latter is superior in several ways.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.logging.log4j.Logger;
import org.opensearch.performanceanalyzer.PerformanceAnalyzerApp;
import org.opensearch.performanceanalyzer.config.PluginSettings;
import org.opensearch.performanceanalyzer.core.Util;
import org.opensearch.performanceanalyzer.metrics.MetricsConfiguration;
import org.opensearch.performanceanalyzer.rca.Version;
import org.opensearch.performanceanalyzer.rca.formatter.StatsCollectorFormatter;
Expand Down Expand Up @@ -146,13 +145,15 @@ private static Map<String, String> loadMetadata(String fileLocation) {

try (InputStream input =
new FileInputStream(
Util.PLUGIN_LOCATION
+ PluginSettings.CONFIG_FILES_PATH
+ fileLocation); ) {
PluginSettings.instance().getConfigFolderPath() + fileLocation); ) {
// load properties file
props.load(input);
} catch (Exception ex) {
GENERAL_LOG.error("Error in loading metadata for fileLocation: {}", fileLocation);
GENERAL_LOG.error(
"Error in loading metadata for folderLocation: {}, fileLocation: {}",
PluginSettings.instance().getConfigFolderPath(),
fileLocation,
ex);
}

props.forEach((key, value) -> retVal.put((String) key, (String) value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

package org.opensearch.performanceanalyzer.config;

import static org.opensearch.performanceanalyzer.core.Util.OPENSEARCH_HOME;

import com.google.common.annotations.VisibleForTesting;
import java.io.File;
Expand All @@ -23,14 +22,6 @@ public class PluginSettings {

private static PluginSettings instance;
public static final String CONFIG_FILES_PATH = "config/";
private static final String DEFAULT_CONFIG_FILE_PATH =
OPENSEARCH_HOME
+ File.separator
+ "config"
+ File.separator
+ "opensearch-performance-analyzer"
+ File.separator
+ "performance-analyzer.properties";
private static final String METRICS_LOCATION_KEY = "metrics-location";
private static final String METRICS_LOCATION_DEFAULT = "/dev/shm/performanceanalyzer/";
private static final String DELETION_INTERVAL_KEY = "metrics-deletion-interval";
Expand Down Expand Up @@ -64,7 +55,8 @@ public class PluginSettings {

private boolean httpsEnabled;
private Properties settings;
private final String configFilePath;
private String configFolderPath;
private String configFilePath;

/**
* Determines how many minutes worth of metricsdb files will be retained if batch metrics is
Expand All @@ -79,6 +71,10 @@ public class PluginSettings {
Util.invokePrivilegedAndLogError(PluginSettings::createInstance);
}

public String getConfigFolderPath() {
return configFolderPath;
}

public String getMetricsLocation() {
return metricsLocation;
}
Expand Down Expand Up @@ -170,9 +166,12 @@ private PluginSettings(String cfPath) {
rpcPort = RPC_DEFAULT_PORT;
webServicePort = WEBSERVICE_DEFAULT_PORT;
if (cfPath == null || cfPath.isEmpty()) {
this.configFilePath = DEFAULT_CONFIG_FILE_PATH;
LOG.error("Config file path is not set. Disabling plugin.");
ConfigStatus.INSTANCE.setConfigurationInvalid();
} else {
this.configFilePath = cfPath;
this.configFolderPath =
cfPath + File.separator + "opensearch-performance-analyzer" + File.separator;
this.configFilePath = configFolderPath + "performance-analyzer.properties";
}

settings = new Properties();
Expand Down Expand Up @@ -216,7 +215,7 @@ public static PluginSettings instance() {
}

private static void createInstance() {
String cfPath = System.getProperty("configFilePath");
String cfPath = System.getProperty("opensearch.path.conf");
instance = new PluginSettings(cfPath);
}

Expand Down

0 comments on commit 8a39c12

Please sign in to comment.