From 6fc7ec49bebf1d5b7a17f0d65212bbcef9f91d7c Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Wed, 27 Jan 2021 11:23:13 -0500 Subject: [PATCH 1/5] [kbn-es] Always use bundled JDK when starting Elasticsearch --- packages/kbn-es/package.json | 3 ++- packages/kbn-es/src/cli_commands/snapshot.js | 2 -- packages/kbn-es/src/cluster.js | 4 +++- packages/kbn-es/src/install/archive.js | 15 +++------------ packages/kbn-es/src/install/snapshot.js | 2 -- 5 files changed, 8 insertions(+), 18 deletions(-) diff --git a/packages/kbn-es/package.json b/packages/kbn-es/package.json index c8e25a95594c6..4f883ae29f0e2 100644 --- a/packages/kbn-es/package.json +++ b/packages/kbn-es/package.json @@ -8,6 +8,7 @@ "devOnly": true }, "scripts": { + "build": "node scripts/build", "kbn:bootstrap": "node scripts/build", "kbn:watch": "node scripts/build --watch" }, @@ -17,4 +18,4 @@ "devDependencies": { "@kbn/babel-preset": "link:../kbn-babel-preset" } -} \ No newline at end of file +} diff --git a/packages/kbn-es/src/cli_commands/snapshot.js b/packages/kbn-es/src/cli_commands/snapshot.js index d66c352a356aa..711992a5895ed 100644 --- a/packages/kbn-es/src/cli_commands/snapshot.js +++ b/packages/kbn-es/src/cli_commands/snapshot.js @@ -62,8 +62,6 @@ exports.run = async (defaults = {}) => { await cluster.extractDataDirectory(installPath, options.dataArchive); } - options.bundledJDK = true; - await cluster.run(installPath, options); } }; diff --git a/packages/kbn-es/src/cluster.js b/packages/kbn-es/src/cluster.js index 60f8a327594d6..6389d07a3e5ff 100644 --- a/packages/kbn-es/src/cluster.js +++ b/packages/kbn-es/src/cluster.js @@ -274,12 +274,14 @@ exports.Cluster = class Cluster { (options.esEnvVars.ES_JAVA_OPTS ? `${options.esEnvVars.ES_JAVA_OPTS} ` : '') + '-Xms1g -Xmx1g'; + // By default, we want to always unset JAVA_HOME so that the bundled JDK will be used + options.esEnvVars.JAVA_HOME = options.esEnvVars.JAVA_HOME || ''; + this._process = execa(ES_BIN, args, { cwd: installPath, env: { ...(installPath ? { ES_TMPDIR: path.resolve(installPath, 'ES_TMPDIR') } : {}), ...process.env, - ...(options.bundledJDK ? { JAVA_HOME: '' } : {}), ...(options.esEnvVars || {}), }, stdio: ['ignore', 'pipe', 'pipe'], diff --git a/packages/kbn-es/src/install/archive.js b/packages/kbn-es/src/install/archive.js index 1e9e19f4533af..5f45f1aa18bbd 100644 --- a/packages/kbn-es/src/install/archive.js +++ b/packages/kbn-es/src/install/archive.js @@ -34,7 +34,6 @@ exports.installArchive = async function installArchive(archive, options = {}) { basePath = BASE_PATH, installPath = path.resolve(basePath, path.basename(archive, '.tar.gz')), log = defaultLog, - bundledJDK = false, esArgs = [], } = options; @@ -64,7 +63,7 @@ exports.installArchive = async function installArchive(archive, options = {}) { await appendToConfig(installPath, 'xpack.security.enabled', 'true'); await appendToConfig(installPath, 'xpack.license.self_generated.type', license); - await configureKeystore(installPath, log, bundledJDK, [ + await configureKeystore(installPath, log, [ ['bootstrap.password', password], ...parseSettings(esArgs, { filter: SettingsFilter.SecureOnly }), ]); @@ -93,16 +92,8 @@ async function appendToConfig(installPath, key, value) { * @param {Array<[string, string]>} secureSettings List of custom Elasticsearch secure settings to * add into the keystore. */ -async function configureKeystore( - installPath, - log = defaultLog, - bundledJDK = false, - secureSettings -) { - const env = {}; - if (bundledJDK) { - env.JAVA_HOME = ''; - } +async function configureKeystore(installPath, log = defaultLog, secureSettings) { + const env = { JAVA_HOME: '' }; await execa(ES_KEYSTORE_BIN, ['create'], { cwd: installPath, env }); for (const [secureSettingName, secureSettingValue] of secureSettings) { diff --git a/packages/kbn-es/src/install/snapshot.js b/packages/kbn-es/src/install/snapshot.js index 55c0e41ea9640..b9562f20d81b7 100644 --- a/packages/kbn-es/src/install/snapshot.js +++ b/packages/kbn-es/src/install/snapshot.js @@ -61,7 +61,6 @@ exports.installSnapshot = async function installSnapshot({ basePath = BASE_PATH, installPath = path.resolve(basePath, version), log = defaultLog, - bundledJDK = true, esArgs, }) { const { downloadPath } = await exports.downloadSnapshot({ @@ -78,7 +77,6 @@ exports.installSnapshot = async function installSnapshot({ basePath, installPath, log, - bundledJDK, esArgs, }); }; From 35f0631f592c2a677c2cd1388722762f49b07327 Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Wed, 27 Jan 2021 11:26:25 -0500 Subject: [PATCH 2/5] Remove accidentally committed change --- packages/kbn-es/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/kbn-es/package.json b/packages/kbn-es/package.json index 4f883ae29f0e2..fd67bfebfa6df 100644 --- a/packages/kbn-es/package.json +++ b/packages/kbn-es/package.json @@ -8,7 +8,6 @@ "devOnly": true }, "scripts": { - "build": "node scripts/build", "kbn:bootstrap": "node scripts/build", "kbn:watch": "node scripts/build --watch" }, From 6ae2650f62cf1451125740a1d06ca02758c316bd Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Wed, 27 Jan 2021 11:30:53 -0500 Subject: [PATCH 3/5] Really revert --- packages/kbn-es/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kbn-es/package.json b/packages/kbn-es/package.json index fd67bfebfa6df..c8e25a95594c6 100644 --- a/packages/kbn-es/package.json +++ b/packages/kbn-es/package.json @@ -17,4 +17,4 @@ "devDependencies": { "@kbn/babel-preset": "link:../kbn-babel-preset" } -} +} \ No newline at end of file From 149cc307b285ef79e8161b722bd7f8ca1f4f414e Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Wed, 27 Jan 2021 11:33:24 -0500 Subject: [PATCH 4/5] Remove param doc as well --- packages/kbn-es/src/install/archive.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/kbn-es/src/install/archive.js b/packages/kbn-es/src/install/archive.js index 5f45f1aa18bbd..80ff4eb6f83b0 100644 --- a/packages/kbn-es/src/install/archive.js +++ b/packages/kbn-es/src/install/archive.js @@ -88,7 +88,6 @@ async function appendToConfig(installPath, key, value) { * * @param {String} installPath * @param {ToolingLog} log - * @param {boolean} bundledJDK * @param {Array<[string, string]>} secureSettings List of custom Elasticsearch secure settings to * add into the keystore. */ From a37ea25625c7b8e674d3ed1c2474f1667ef51b6e Mon Sep 17 00:00:00 2001 From: Brian Seeders Date: Wed, 27 Jan 2021 14:06:03 -0500 Subject: [PATCH 5/5] PR feedback --- packages/kbn-es/src/cluster.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/kbn-es/src/cluster.js b/packages/kbn-es/src/cluster.js index 6389d07a3e5ff..f554dd8a1b8e5 100644 --- a/packages/kbn-es/src/cluster.js +++ b/packages/kbn-es/src/cluster.js @@ -274,14 +274,12 @@ exports.Cluster = class Cluster { (options.esEnvVars.ES_JAVA_OPTS ? `${options.esEnvVars.ES_JAVA_OPTS} ` : '') + '-Xms1g -Xmx1g'; - // By default, we want to always unset JAVA_HOME so that the bundled JDK will be used - options.esEnvVars.JAVA_HOME = options.esEnvVars.JAVA_HOME || ''; - this._process = execa(ES_BIN, args, { cwd: installPath, env: { ...(installPath ? { ES_TMPDIR: path.resolve(installPath, 'ES_TMPDIR') } : {}), ...process.env, + JAVA_HOME: '', // By default, we want to always unset JAVA_HOME so that the bundled JDK will be used ...(options.esEnvVars || {}), }, stdio: ['ignore', 'pipe', 'pipe'],