[Rename] Environment variables in entire repository. (#405)

Rename all environment variables with prefix 'ES_' to 'OPENSEARCH_'.

Signed-off-by: Rabi Panda <adnapibar@gmail.com>
This commit is contained in:
Rabi Panda 2021-03-18 17:17:19 -07:00 committed by Nick Knize
parent df11cc9de4
commit 127243b83b
23 changed files with 62 additions and 62 deletions

View File

@ -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=

View File

@ -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

View File

@ -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\"
@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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}")

View File

@ -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)) {

View File

@ -81,9 +81,9 @@ public class BwcSetupExtension {
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("!!"))
)
)
@ -94,9 +94,9 @@ public class BwcSetupExtension {
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("!!"))
)
)

View File

@ -729,17 +729,17 @@ public class OpenSearchNode implements TestClusterConfiguration {
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 = "";
@ -754,13 +754,13 @@ public class OpenSearchNode implements TestClusterConfiguration {
}
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

View File

@ -1,6 +1,6 @@
# 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
@ -8,7 +8,7 @@ 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 \
@ -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

View File

@ -55,7 +55,7 @@ public class SystemdPlugin extends Plugin implements ClusterPlugin {
@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) {
@ -69,13 +69,13 @@ public class SystemdPlugin extends Plugin implements ClusterPlugin {
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);
}

View File

@ -93,7 +93,7 @@ public class SystemdPluginTests extends OpenSearchTestCase {
() -> 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() {

View File

@ -250,7 +250,7 @@ public class ArchiveTests extends PackagingTestCase {
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();

View File

@ -167,7 +167,7 @@ public class DockerTests extends PackagingTestCase {
// 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);

View File

@ -259,7 +259,7 @@ public class KeystoreManagementTests extends PackagingTestCase {
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));
@ -268,7 +268,7 @@ public class KeystoreManagementTests extends PackagingTestCase {
ServerUtils.runOpenSearchTests();
stopOpenSearch();
} finally {
sh.run("sudo systemctl unset-environment ES_KEYSTORE_PASSPHRASE_FILE");
sh.run("sudo systemctl unset-environment OPENSEARCH_KEYSTORE_PASSPHRASE_FILE");
}
}
@ -279,7 +279,7 @@ public class KeystoreManagementTests extends PackagingTestCase {
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);
@ -292,7 +292,7 @@ public class KeystoreManagementTests extends PackagingTestCase {
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");
}
}

View File

@ -303,7 +303,7 @@ public class PackageTests extends PackagingTestCase {
stopOpenSearch();
withCustomConfig(tempConf -> {
append(installation.envFile, "ES_JAVA_OPTS=-XX:-UseCompressedOops");
append(installation.envFile, "OPENSEARCH_JAVA_OPTS=-XX:-UseCompressedOops");
startOpenSearch();

View File

@ -376,7 +376,7 @@ public abstract class PackagingTestCase extends Assert {
// 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' |"
@ -432,9 +432,9 @@ public abstract class PackagingTestCase extends Assert {
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);
@ -442,7 +442,7 @@ public abstract class PackagingTestCase extends Assert {
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);
}

View File

@ -117,7 +117,7 @@ public class PluginCliTests extends PackagingTestCase {
}
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")));
}

View File

@ -273,11 +273,11 @@ public class WindowsServiceTests extends PackagingTestCase {
}
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 {

View File

@ -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());
@ -233,7 +233,7 @@ public class Archives {
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);
}
@ -258,7 +258,7 @@ public class Archives {
}
// 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 ");
@ -332,7 +332,7 @@ public class Archives {
+ keystorePassword
+ "'); "
+ "Wait-Process -Timeout "
+ ES_STARTUP_SLEEP_TIME_SECONDS
+ OPENSEARCH_STARTUP_SLEEP_TIME_SECONDS
+ " -Id $process.Id; "
+ "$process.Id;"
);

View File

@ -9,7 +9,7 @@ services:
- cluster.name=opensearch-oss-1
- bootstrap.memory_lock=true
- network.publish_host=127.0.0.1
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
- path.repo=/tmp/opensearch-repo
- node.attr.testattr=test
- cluster.routing.allocation.disk.watermark.low=1b
@ -43,7 +43,7 @@ services:
- cluster.name=opensearch-oss-2
- bootstrap.memory_lock=true
- network.publish_host=127.0.0.1
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
- path.repo=/tmp/opensearch-repo
- node.attr.testattr=test
- cluster.routing.allocation.disk.watermark.low=1b

View File

@ -94,7 +94,7 @@ import static org.opensearch.bootstrap.FilePermissionUtils.addSingleFilePath;
* <h2>Debugging Security</h2>
* A good place to start when there is a problem is to turn on security debugging:
* <pre>
* ES_JAVA_OPTS="-Djava.security.debug=access,failure" bin/opensearch
* OPENSEARCH_JAVA_OPTS="-Djava.security.debug=access,failure" bin/opensearch
* </pre>
* <p>
* When running tests you have to pass it to the test runner like this: