Skip to content

Commit

Permalink
[Rename] Environment variables in entire repository. (#405)
Browse files Browse the repository at this point in the history
Rename all environment variables with prefix 'ES_' to 'OPENSEARCH_'.

Signed-off-by: Rabi Panda <adnapibar@gmail.com>
  • Loading branch information
adnapibar authored and nknize committed Mar 20, 2021
1 parent cb9fdcd commit 88398d8
Show file tree
Hide file tree
Showing 23 changed files with 62 additions and 62 deletions.
4 changes: 2 additions & 2 deletions .ci/java-versions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# build and test Elasticsearch for this branch. Valid Java versions
# are 'java' or 'openjdk' followed by the major release number.

ES_BUILD_JAVA=openjdk14
ES_RUNTIME_JAVA=java8
OPENSEARCH_BUILD_JAVA=openjdk14
OPENSEARCH_RUNTIME_JAVA=java8
GRADLE_TASK=build
GRADLE_EXTRA_ARGS=
2 changes: 1 addition & 1 deletion .ci/matrix-runtime-javas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# which Elasticsearch will be tested. Valid Java versions are 'java'
# or 'openjdk' followed by the major release number.

ES_RUNTIME_JAVA:
OPENSEARCH_RUNTIME_JAVA:
- java8
- java11
- openjdk14
Expand Down
8 changes: 4 additions & 4 deletions .ci/os.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdent
}

$AppProps = ConvertFrom-StringData (Get-Content .ci/java-versions.properties -raw)
$env:ES_BUILD_JAVA=$AppProps.ES_BUILD_JAVA
$env:ES_RUNTIME_JAVA=$AppProps.ES_RUNTIME_JAVA
$env:OPENSEARCH_BUILD_JAVA=$AppProps.OPENSEARCH_BUILD_JAVA
$env:OPENSEARCH_RUNTIME_JAVA=$AppProps.OPENSEARCH_RUNTIME_JAVA

$ErrorActionPreference="Stop"
$gradleInit = "C:\Users\$env:username\.gradle\init.d\"
Expand All @@ -20,9 +20,9 @@ echo "Copy .ci/init.gradle to $gradleInit"
Copy-Item .ci/init.gradle -Destination $gradleInit

[Environment]::SetEnvironmentVariable("JAVA_HOME", $null, "Machine")
$env:PATH="C:\Users\jenkins\.java\$env:ES_BUILD_JAVA\bin\;$env:PATH"
$env:PATH="C:\Users\jenkins\.java\$env:OPENSEARCH_BUILD_JAVA\bin\;$env:PATH"
$env:JAVA_HOME=$null
$env:SYSTEM_JAVA_HOME="C:\Users\jenkins\.java\$env:ES_RUNTIME_JAVA"
$env:SYSTEM_JAVA_HOME="C:\Users\jenkins\.java\$env:OPENSEARCH_RUNTIME_JAVA"
Remove-Item -Recurse -Force \tmp -ErrorAction Ignore
New-Item -ItemType directory -Path \tmp

Expand Down
4 changes: 2 additions & 2 deletions .ci/os.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ sudo useradd vagrant
set -e

. .ci/java-versions.properties
RUNTIME_JAVA_HOME=$HOME/.java/$ES_RUNTIME_JAVA
BUILD_JAVA_HOME=$HOME/.java/$ES_BUILD_JAVA
RUNTIME_JAVA_HOME=$HOME/.java/$OPENSEARCH_RUNTIME_JAVA
BUILD_JAVA_HOME=$HOME/.java/$OPENSEARCH_BUILD_JAVA

rm -Rfv $HOME/.gradle/init.d/ && mkdir -p $HOME/.gradle/init.d
cp -v .ci/init.gradle $HOME/.gradle/init.d
Expand Down
2 changes: 1 addition & 1 deletion .ci/packer_cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ while [ -h "$SCRIPT" ] ; do
done

source $(dirname "${SCRIPT}")/java-versions.properties
export JAVA_HOME="${HOME}"/.java/${ES_BUILD_JAVA}
export JAVA_HOME="${HOME}"/.java/${OPENSEARCH_BUILD_JAVA}
# We are caching BWC versions too, need these so we can build those
export JAVA8_HOME="${HOME}"/.java/java8
export JAVA11_HOME="${HOME}"/.java/java11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
# specific language governing permissions and limitations
# under the License.
#
ES_BUILD_JAVA=openjdk14
ES_RUNTIME_JAVA=openjdk14
OPENSEARCH_BUILD_JAVA=openjdk14
OPENSEARCH_RUNTIME_JAVA=openjdk14
GRADLE_TASK=build
Original file line number Diff line number Diff line change
Expand Up @@ -758,24 +758,24 @@ class ClusterFormationTasks {
}

// Configure ES JAVA OPTS - adds system properties, assertion flags, remote debug etc
List<String> esJavaOpts = [node.env.get('ES_JAVA_OPTS', '')]
List<String> opensearchJavaOpts = [node.env.get('OPENSEARCH_JAVA_OPTS', '')]
String collectedSystemProperties = node.config.systemProperties.collect { key, value -> "-D${key}=${value}" }.join(" ")
esJavaOpts.add(collectedSystemProperties)
esJavaOpts.add(node.config.jvmArgs)
opensearchJavaOpts.add(collectedSystemProperties)
opensearchJavaOpts.add(node.config.jvmArgs)
if (Boolean.parseBoolean(System.getProperty('tests.asserts', 'true'))) {
// put the enable assertions options before other options to allow
// flexibility to disable assertions for specific packages or classes
// in the cluster-specific options
esJavaOpts.add("-ea")
esJavaOpts.add("-esa")
opensearchJavaOpts.add("-ea")
opensearchJavaOpts.add("-esa")
}
// we must add debug options inside the closure so the config is read at execution time, as
// gradle task options are not processed until the end of the configuration phase
if (node.config.debug) {
println 'Running opensearch in debug mode, suspending until connected on port 8000'
esJavaOpts.add('-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000')
opensearchJavaOpts.add('-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000')
}
node.env['ES_JAVA_OPTS'] = esJavaOpts.join(" ")
node.env['OPENSEARCH_JAVA_OPTS'] = opensearchJavaOpts.join(" ")

//
project.logger.info("Starting node in ${node.clusterName} distribution: ${node.config.distribution}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ class NodeInfo {
* We have to delay building the string as the path will not exist during configuration which will fail on Windows due to
* getting the short name requiring the path to already exist.
*/
env.put('ES_PATH_CONF', "${-> getShortPathName(pathConf.toString())}")
env.put('OPENSEARCH_PATH_CONF', "${-> getShortPathName(pathConf.toString())}")
}
else {
env.put('ES_PATH_CONF', pathConf)
env.put('OPENSEARCH_PATH_CONF', pathConf)
}
if (!System.properties.containsKey("tests.opensearch.path.data")) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ private TaskProvider<LoggedExec> createRunBwcGradleTask(Project project, String
Integer.parseInt(
Arrays.asList(javaVersionsString.split("\n"))
.stream()
.filter(l -> l.trim().startsWith("ES_BUILD_JAVA="))
.map(l -> l.replace("ES_BUILD_JAVA=java", "").trim())
.map(l -> l.replace("ES_BUILD_JAVA=openjdk", "").trim())
.filter(l -> l.trim().startsWith("OPENSEARCH_BUILD_JAVA="))
.map(l -> l.replace("OPENSEARCH_BUILD_JAVA=java", "").trim())
.map(l -> l.replace("OPENSEARCH_BUILD_JAVA=openjdk", "").trim())
.collect(Collectors.joining("!!"))
)
)
Expand All @@ -94,9 +94,9 @@ private TaskProvider<LoggedExec> createRunBwcGradleTask(Project project, String
Integer.parseInt(
Arrays.asList(javaVersionsString.split("\n"))
.stream()
.filter(l -> l.trim().startsWith("ES_RUNTIME_JAVA="))
.map(l -> l.replace("ES_RUNTIME_JAVA=java", "").trim())
.map(l -> l.replace("ES_RUNTIME_JAVA=openjdk", "").trim())
.filter(l -> l.trim().startsWith("OPENSEARCH_RUNTIME_JAVA="))
.map(l -> l.replace("OPENSEARCH_RUNTIME_JAVA=java", "").trim())
.map(l -> l.replace("OPENSEARCH_RUNTIME_JAVA=openjdk", "").trim())
.collect(Collectors.joining("!!"))
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -729,17 +729,17 @@ private void runOpenSearchBinScript(String tool, CharSequence... args) {
private Map<String, String> getESEnvironment() {
Map<String, String> defaultEnv = new HashMap<>();
getRequiredJavaHome().ifPresent(javaHome -> defaultEnv.put("JAVA_HOME", javaHome));
defaultEnv.put("ES_PATH_CONF", configFile.getParent().toString());
defaultEnv.put("OPENSEARCH_PATH_CONF", configFile.getParent().toString());
String systemPropertiesString = "";
if (systemProperties.isEmpty() == false) {
systemPropertiesString = " "
+ systemProperties.entrySet()
.stream()
.map(entry -> "-D" + entry.getKey() + "=" + entry.getValue())
// ES_PATH_CONF is also set as an environment variable and for a reference to ${ES_PATH_CONF}
// to work ES_JAVA_OPTS, we need to make sure that ES_PATH_CONF before ES_JAVA_OPTS. Instead,
// OPENSEARCH_PATH_CONF is also set as an environment variable and for a reference to ${OPENSEARCH_PATH_CONF}
// to work OPENSEARCH_JAVA_OPTS, we need to make sure that OPENSEARCH_PATH_CONF before OPENSEARCH_JAVA_OPTS. Instead,
// we replace the reference with the actual value in other environment variables
.map(p -> p.replace("${ES_PATH_CONF}", configFile.getParent().toString()))
.map(p -> p.replace("${OPENSEARCH_PATH_CONF}", configFile.getParent().toString()))
.collect(Collectors.joining(" "));
}
String jvmArgsString = "";
Expand All @@ -754,13 +754,13 @@ private Map<String, String> getESEnvironment() {
}
String heapSize = System.getProperty("tests.heap.size", "512m");
defaultEnv.put(
"ES_JAVA_OPTS",
"OPENSEARCH_JAVA_OPTS",
"-Xms" + heapSize + " -Xmx" + heapSize + " -ea -esa " + systemPropertiesString + " " + jvmArgsString + " " +
// Support passing in additional JVM arguments
System.getProperty("tests.jvm.argline", "")
);
defaultEnv.put("ES_TMPDIR", tmpDir.toString());
// Windows requires this as it defaults to `c:\windows` despite ES_TMPDIR
defaultEnv.put("OPENSEARCH_TMPDIR", tmpDir.toString());
// Windows requires this as it defaults to `c:\windows` despite OPENSEARCH_TMPDIR
defaultEnv.put("TMP", tmpDir.toString());

// Override the system hostname variables for testing
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# ca.p12

$ES_HOME/bin/elasticsearch-certutil ca --out ca.p12 --pass "ca-password" --days 9999
$OPENSEARCH_HOME/bin/elasticsearch-certutil ca --out ca.p12 --pass "ca-password" --days 9999

# ca.pem

openssl pkcs12 -info -in ./ca.p12 -nokeys -out ca.pem -passin "pass:ca-password"

# http.p12

$ES_HOME/bin/elasticsearch-certutil cert --out http.zip --pass "http-password" \
$OPENSEARCH_HOME/bin/elasticsearch-certutil cert --out http.zip --pass "http-password" \
--days 9999 --pem --name "http" \
--ca ca.p12 --ca-pass "ca-password" \
--dns=localhost --dns=localhost.localdomain --dns=localhost4 --dns=localhost4.localdomain4 --dns=localhost6 --dns=localhost6.localdomain6 \
Expand All @@ -18,7 +18,7 @@ rm http.zip

# client.p12

$ES_HOME/bin/elasticsearch-certutil cert --out client.zip --pass "client-password" \
$OPENSEARCH_HOME/bin/elasticsearch-certutil cert --out client.zip --pass "client-password" \
--name "client" --days 9999 --pem \
--ca ca.p12 --ca-pass "ca-password"
unzip client.zip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ final boolean isEnabled() {

@SuppressWarnings("unused")
public SystemdPlugin() {
this(true, Build.CURRENT.type(), System.getenv("ES_SD_NOTIFY"));
this(true, Build.CURRENT.type(), System.getenv("OPENSEARCH_SD_NOTIFY"));
}

SystemdPlugin(final boolean assertIsPackageDistribution, final Build.Type buildType, final String esSDNotify) {
Expand All @@ -69,13 +69,13 @@ public SystemdPlugin() {
enabled = false;
return;
}
logger.trace("ES_SD_NOTIFY is set to [{}]", esSDNotify);
logger.trace("OPENSEARCH_SD_NOTIFY is set to [{}]", esSDNotify);
if (esSDNotify == null) {
enabled = false;
return;
}
if (Boolean.TRUE.toString().equals(esSDNotify) == false && Boolean.FALSE.toString().equals(esSDNotify) == false) {
throw new RuntimeException("ES_SD_NOTIFY set to unexpected value [" + esSDNotify + "]");
throw new RuntimeException("OPENSEARCH_SD_NOTIFY set to unexpected value [" + esSDNotify + "]");
}
enabled = Boolean.TRUE.toString().equals(esSDNotify);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void testInvalid() {
() -> randomAlphaOfLength(4));
final RuntimeException e = expectThrows(RuntimeException.class,
() -> new SystemdPlugin(false, randomPackageBuildType, esSDNotify));
assertThat(e, hasToString(containsString("ES_SD_NOTIFY set to unexpected value [" + esSDNotify + "]")));
assertThat(e, hasToString(containsString("OPENSEARCH_SD_NOTIFY set to unexpected value [" + esSDNotify + "]")));
}

public void testOnNodeStartedSuccess() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public void test70CustomPathConfAndJvmOptions() throws Exception {
final List<String> jvmOptions = org.opensearch.common.collect.List.of("-Xms512m", "-Xmx512m", "-Dlog4j2.disable.jmx=true");
Files.write(tempConf.resolve("jvm.options"), jvmOptions, CREATE, APPEND);

sh.getEnv().put("ES_JAVA_OPTS", "-XX:-UseCompressedOops");
sh.getEnv().put("OPENSEARCH_JAVA_OPTS", "-XX:-UseCompressedOops");

startOpenSearch();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public void test070BindMountCustomPathConfAndJvmOptions() throws Exception {

// Restart the container
final Map<Path, Path> volumes = singletonMap(tempDir, Paths.get("/usr/share/opensearch/config"));
final Map<String, String> envVars = singletonMap("ES_JAVA_OPTS", "-XX:-UseCompressedOops");
final Map<String, String> envVars = singletonMap("OPENSEARCH_JAVA_OPTS", "-XX:-UseCompressedOops");
runContainer(distribution(), volumes, envVars);

waitForOpenSearch(installation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public void test50KeystorePasswordFromFile() throws Exception {
assertPasswordProtectedKeystore();

try {
sh.run("sudo systemctl set-environment ES_KEYSTORE_PASSPHRASE_FILE=" + esKeystorePassphraseFile);
sh.run("sudo systemctl set-environment OPENSEARCH_KEYSTORE_PASSPHRASE_FILE=" + esKeystorePassphraseFile);

Files.createFile(esKeystorePassphraseFile);
Files.write(esKeystorePassphraseFile, singletonList(password));
Expand All @@ -268,7 +268,7 @@ public void test50KeystorePasswordFromFile() throws Exception {
ServerUtils.runOpenSearchTests();
stopOpenSearch();
} finally {
sh.run("sudo systemctl unset-environment ES_KEYSTORE_PASSPHRASE_FILE");
sh.run("sudo systemctl unset-environment OPENSEARCH_KEYSTORE_PASSPHRASE_FILE");
}
}

Expand All @@ -279,7 +279,7 @@ public void test51WrongKeystorePasswordFromFile() throws Exception {
assertPasswordProtectedKeystore();

try {
sh.run("sudo systemctl set-environment ES_KEYSTORE_PASSPHRASE_FILE=" + esKeystorePassphraseFile);
sh.run("sudo systemctl set-environment OPENSEARCH_KEYSTORE_PASSPHRASE_FILE=" + esKeystorePassphraseFile);

if (Files.exists(esKeystorePassphraseFile)) {
rm(esKeystorePassphraseFile);
Expand All @@ -292,7 +292,7 @@ public void test51WrongKeystorePasswordFromFile() throws Exception {
Shell.Result result = runOpenSearchStartCommand(null, false, false);
assertOpenSearchFailure(result, Arrays.asList(ERROR_INCORRECT_PASSWORD, ERROR_CORRUPTED_KEYSTORE), journaldWrapper);
} finally {
sh.run("sudo systemctl unset-environment ES_KEYSTORE_PASSPHRASE_FILE");
sh.run("sudo systemctl unset-environment OPENSEARCH_KEYSTORE_PASSPHRASE_FILE");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public void test81CustomPathConfAndJvmOptions() throws Exception {
stopOpenSearch();

withCustomConfig(tempConf -> {
append(installation.envFile, "ES_JAVA_OPTS=-XX:-UseCompressedOops");
append(installation.envFile, "OPENSEARCH_JAVA_OPTS=-XX:-UseCompressedOops");

startOpenSearch();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public void assertOpenSearchFailure(Shell.Result result, List<String> expectedMe
// In Windows, we have written our stdout and stderr to files in order to run
// in the background
String wrapperPid = result.stdout.trim();
sh.runIgnoreExitCode("Wait-Process -Timeout " + Archives.ES_STARTUP_SLEEP_TIME_SECONDS + " -Id " + wrapperPid);
sh.runIgnoreExitCode("Wait-Process -Timeout " + Archives.OPENSEARCH_STARTUP_SLEEP_TIME_SECONDS + " -Id " + wrapperPid);
sh.runIgnoreExitCode(
"Get-EventSubscriber | "
+ "where {($_.EventName -eq 'OutputDataReceived' -Or $_.EventName -eq 'ErrorDataReceived' |"
Expand Down Expand Up @@ -432,17 +432,17 @@ public void withCustomConfig(CheckedConsumer<Path, Exception> action) throws Exc

if (distribution.isPackage()) {
Files.copy(installation.envFile, tempDir.resolve("opensearch.bk"));// backup
append(installation.envFile, "ES_PATH_CONF=" + tempConf + "\n");
append(installation.envFile, "OPENSEARCH_PATH_CONF=" + tempConf + "\n");
} else {
sh.getEnv().put("ES_PATH_CONF", tempConf.toString());
sh.getEnv().put("OPENSEARCH_PATH_CONF", tempConf.toString());
}

action.accept(tempConf);
if (distribution.isPackage()) {
IOUtils.rm(installation.envFile);
Files.copy(tempDir.resolve("opensearch.bk"), installation.envFile);
} else {
sh.getEnv().remove("ES_PATH_CONF");
sh.getEnv().remove("OPENSEARCH_PATH_CONF");
}
IOUtils.rm(tempDir);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void test23OpenSearchWithSpace() throws Exception {
}

public void test24JavaOpts() throws Exception {
sh.getEnv().put("ES_JAVA_OPTS", "-XX:+PrintFlagsFinal");
sh.getEnv().put("OPENSEARCH_JAVA_OPTS", "-XX:+PrintFlagsFinal");
assertWithExamplePlugin(installResult -> assertThat(installResult.stdout, containsString("MaxHeapSize")));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,11 @@ public void test70UnknownCommand() {
}

public void test80JavaOptsInEnvVar() throws Exception {
sh.getEnv().put("ES_JAVA_OPTS", "-Xmx2g -Xms2g");
sh.getEnv().put("OPENSEARCH_JAVA_OPTS", "-Xmx2g -Xms2g");
sh.run(serviceScript + " install");
assertCommand(serviceScript + " start");
assertStartedAndStop();
sh.getEnv().remove("ES_JAVA_OPTS");
sh.getEnv().remove("OPENSEARCH_JAVA_OPTS");
}

public void test81JavaOptsInJvmOptions() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class Archives {

/** This is an arbitrarily chosen value that gives OpenSearch time to log Bootstrap
* errors to the console if they occur before the logging framework is initialized. */
public static final String ES_STARTUP_SLEEP_TIME_SECONDS = "10";
public static final String OPENSEARCH_STARTUP_SLEEP_TIME_SECONDS = "10";

public static Installation installArchive(Shell sh, Distribution distribution) throws Exception {
return installArchive(sh, distribution, getDefaultArchiveInstallPath(), getCurrentVersion());
Expand Down Expand Up @@ -233,7 +233,7 @@ public static Shell.Result startOpenSearchWithTty(Installation installation, She
keystorePassword
);

sh.getEnv().put("ES_STARTUP_SLEEP_TIME", ES_STARTUP_SLEEP_TIME_SECONDS);
sh.getEnv().put("OPENSEARCH_STARTUP_SLEEP_TIME", OPENSEARCH_STARTUP_SLEEP_TIME_SECONDS);
return sh.runIgnoreExitCode(script);
}

Expand All @@ -258,7 +258,7 @@ public static Shell.Result runOpenSearchStartCommand(
}

// We need to give OpenSearch enough time to print failures to stderr before exiting
sh.getEnv().put("ES_STARTUP_SLEEP_TIME", ES_STARTUP_SLEEP_TIME_SECONDS);
sh.getEnv().put("OPENSEARCH_STARTUP_SLEEP_TIME", OPENSEARCH_STARTUP_SLEEP_TIME_SECONDS);

List<String> command = new ArrayList<>();
command.add("sudo -E -u ");
Expand Down Expand Up @@ -332,7 +332,7 @@ public static Shell.Result runOpenSearchStartCommand(
+ keystorePassword
+ "'); "
+ "Wait-Process -Timeout "
+ ES_STARTUP_SLEEP_TIME_SECONDS
+ OPENSEARCH_STARTUP_SLEEP_TIME_SECONDS
+ " -Id $process.Id; "
+ "$process.Id;"
);
Expand Down
Loading

0 comments on commit 88398d8

Please sign in to comment.