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 rpm build by adding config to env variable #172

Merged
merged 1 commit into from
Apr 27, 2022
Merged
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
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 @@ -23,14 +23,15 @@ public class PluginSettings {

private static PluginSettings instance;
public static final String CONFIG_FILES_PATH = "config/";
private static final String DEFAULT_CONFIG_FILE_PATH =
public static final String DEFAULT_CONFIG_FOLDER_PATH =
OPENSEARCH_HOME
+ File.separator
+ "config"
+ File.separator
+ "opensearch-performance-analyzer"
+ File.separator
+ "performance-analyzer.properties";
+ File.separator;
private static final String DEFAULT_CONFIG_FILE_PATH =
DEFAULT_CONFIG_FOLDER_PATH + "performance-analyzer.properties";
Comment on lines +26 to +34
Copy link
Member

Choose a reason for hiding this comment

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

Are we still using OPENSEARCH_HOME here for the default config folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using OPENSEARCH_HOME here for the default config folder. Removing the default maybe a better idea. Any thoughts?

performance-analyzer-agent which starts the PA process will never succeed if the setting is not present, which means this DEFAULT value will never be used.

Copy link
Member

Choose a reason for hiding this comment

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

I am ok to remove the var if never used.

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,6 +65,7 @@ public class PluginSettings {

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

/**
Expand All @@ -79,6 +81,10 @@ public class PluginSettings {
Util.invokePrivilegedAndLogError(PluginSettings::createInstance);
}

public String getConfigFolderPath() {
return configFolderPath;
}

public String getMetricsLocation() {
return metricsLocation;
}
Expand Down Expand Up @@ -170,9 +176,12 @@ private PluginSettings(String cfPath) {
rpcPort = RPC_DEFAULT_PORT;
webServicePort = WEBSERVICE_DEFAULT_PORT;
if (cfPath == null || cfPath.isEmpty()) {
this.configFolderPath = DEFAULT_CONFIG_FOLDER_PATH;
this.configFilePath = DEFAULT_CONFIG_FILE_PATH;
} 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 +225,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