-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move declarative plugin sync to server cli (#87273)
When running in Docker, the elasticsearch-plugins.yml allows configuring plugins that should be installed in the system. Upon Elasticsearch starting up, plugins are installed/removed to match the configured plugins. However, this happens late in startup, and it would be nice to keep the main Elasticsearch process from ever writing outside the configured data directories. Now that the server cli has been moved to Java, this is possible. This commit moves invocation of the plugins sync command into the server cli. Note that the sync plugins action should probably be reworked as it can be implement Command directly now. However, this commit tries to be the minimal change possible to remove plugin cli knowledge from server.
- Loading branch information
Showing
12 changed files
with
127 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
.../tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/SyncPluginsCliProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.plugins.cli; | ||
|
||
import joptsimple.OptionSet; | ||
|
||
import org.elasticsearch.Build; | ||
import org.elasticsearch.cli.CliToolProvider; | ||
import org.elasticsearch.cli.Command; | ||
import org.elasticsearch.cli.ExitCodes; | ||
import org.elasticsearch.cli.ProcessInfo; | ||
import org.elasticsearch.cli.Terminal; | ||
import org.elasticsearch.cli.UserException; | ||
import org.elasticsearch.common.cli.EnvironmentAwareCommand; | ||
import org.elasticsearch.env.Environment; | ||
|
||
import java.nio.file.Files; | ||
|
||
import static org.elasticsearch.plugins.cli.SyncPluginsAction.ELASTICSEARCH_PLUGINS_YML; | ||
|
||
public class SyncPluginsCliProvider implements CliToolProvider { | ||
@Override | ||
public String name() { | ||
return "sync-plugins"; | ||
} | ||
|
||
@Override | ||
public Command create() { | ||
return new EnvironmentAwareCommand("sync installed plugins from elasticsearch-plugins.yml") { | ||
@Override | ||
public void execute(Terminal terminal, OptionSet options, Environment env, ProcessInfo processInfo) throws Exception { | ||
var action = new SyncPluginsAction(terminal, env); | ||
if (Files.exists(env.configFile().resolve(ELASTICSEARCH_PLUGINS_YML)) == false) { | ||
return; | ||
} | ||
if (Build.CURRENT.type() != Build.Type.DOCKER) { | ||
throw new UserException( | ||
ExitCodes.CONFIG, | ||
"Can only use [elasticsearch-plugins.yml] config file with distribution type [docker]" | ||
); | ||
} | ||
try { | ||
action.execute(); | ||
} catch (PluginSyncException e) { | ||
throw new UserException(ExitCodes.CONFIG, ELASTICSEARCH_PLUGINS_YML + ": " + e.getMessage()); | ||
} | ||
} | ||
}; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ols/plugin-cli/src/main/resources/META-INF/services/org.elasticsearch.cli.CliToolProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
org.elasticsearch.plugins.cli.PluginCliProvider | ||
org.elasticsearch.plugins.cli.SyncPluginsCliProvider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 0 additions & 59 deletions
59
server/src/main/java/org/elasticsearch/bootstrap/plugins/LoggerTerminal.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.