Skip to content

Commit

Permalink
Adding yarn opensearch args to setup opensearch plugin dependencies o…
Browse files Browse the repository at this point in the history
…n snapshot

Signed-off-by: Manasvini B Suryanarayana <manasvis@amazon.com>
  • Loading branch information
manasvinibs committed Nov 8, 2022
1 parent fe4b860 commit 694731a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Multi DataSource] Update MD data source documentation link ([#2693](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2693))
- [Save Object Aggregation View] Add extension point in saved object management to register namespaces and show filter ([#2656](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2656))
- [Save Object Aggregation View] Fix for export all after scroll count response changed in PR#2656 ([#2696](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2696))
<<<<<<< HEAD
- [Vis Builder] Add an experimental table visualization in vis builder ([#2705](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2705))
- [Vis Builder] Add field summary popovers ([#2682](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2682))
=======
- Add yarn opensearch arg to setup plugin dependencies ([#2544](https://github.com/opensearch-project/OpenSearch-Dashboards/issues/2544))
>>>>>>> Adding yarn opensearch args to setup opensearch plugin dependencies on snapshot
### 🐛 Bug Fixes

Expand Down
6 changes: 6 additions & 0 deletions packages/osd-opensearch/src/cli_commands/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ exports.help = (defaults = {}) => {
-E Additional key=value settings to pass to OpenSearch
--download-only Download the snapshot but don't actually start it
--ssl Sets up SSL on OpenSearch
--P OpenSearch plugin artifact URL to install it on the cluster.
Example:
Expand All @@ -64,6 +65,7 @@ exports.run = async (defaults = {}) => {
installPath: 'install-path',
dataArchive: 'data-archive',
opensearchArgs: 'E',
opensearchPlugins: 'P',
},

string: ['version'],
Expand All @@ -83,6 +85,10 @@ exports.run = async (defaults = {}) => {
await cluster.extractDataDirectory(installPath, options.dataArchive);
}

if (options.opensearchPlugins) {
await cluster.installOpensearchPlugin(installPath, options.opensearchPlugins);
}

options.bundledJDK = true;

await cluster.run(installPath, options);
Expand Down
28 changes: 27 additions & 1 deletion packages/osd-opensearch/src/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const execa = require('execa');
const chalk = require('chalk');
const path = require('path');
const { downloadSnapshot, installSnapshot, installSource, installArchive } = require('./install');
const { OPENSEARCH_BIN } = require('./paths');
const { OPENSEARCH_BIN, OPENSEARCH_PLUGIN } = require('./paths');
const { log: defaultLog, parseOpenSearchLog, extractConfigFiles, decompress } = require('./utils');
const { createCliError } = require('./errors');
const { promisify } = require('util');
Expand Down Expand Up @@ -170,6 +170,32 @@ exports.Cluster = class Cluster {
this._log.indent(-4);
}

/**
* Unpacks a tar or zip file containing the opensearch plugin directory for an
* OpenSearch cluster.
*
* @param {string} installPath
* @param {Array|string} opensearchPlugins Array or string of opensearch plugin(s) artifact url
*/
async installOpensearchPlugin(installPath, opensearchPluginsPath) {
this._log.info(chalk.bold(`Downloading Opensearch plugin on the cluster snapshot`));
this._log.indent(4);
// Run opensearch-plugin tool script to download openSearch plugin artifacts
if (Array.isArray(opensearchPluginsPath)) {
for (const pluginPath of opensearchPluginsPath) {
this._log.info(`Installing OpenSearch Plugin from the path: ${pluginPath}`);
await execa(OPENSEARCH_PLUGIN, [`install`, `--batch`, pluginPath], { cwd: installPath });
}
} else if (typeof opensearchPluginsPath === 'string') {
this._log.info(`Installing OpenSearch Plugin from the path: ${opensearchPluginsPath}`);
await execa(OPENSEARCH_PLUGIN, [`install`, `--batch`, opensearchPluginsPath], {
cwd: installPath,
});
}
this._log.info(`Plugin download complete`);
this._log.indent(-4);
}

/**
* Starts OpenSearch and returns resolved promise once started
*
Expand Down
1 change: 1 addition & 0 deletions packages/osd-opensearch/src/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ exports.OPENSEARCH_BIN = maybeUseBat('bin/opensearch');
exports.OPENSEARCH_CONFIG = 'config/opensearch.yml';

exports.OPENSEARCH_KEYSTORE_BIN = maybeUseBat('./bin/opensearch-keystore');
exports.OPENSEARCH_PLUGIN = maybeUseBat('./bin/opensearch-plugin');

0 comments on commit 694731a

Please sign in to comment.