1
0
Эх сурвалжийг харах

Merge pull request #18594 from jasontedor/plugins-cleanup

Plugins cleanup
Jason Tedor 9 жил өмнө
parent
commit
d23db39445

+ 1 - 1
core/src/main/java/org/elasticsearch/bootstrap/Security.java

@@ -244,7 +244,7 @@ final class Security {
         addPath(policy, Environment.PATH_HOME_SETTING.getKey(), environment.binFile(), "read,readlink");
         addPath(policy, Environment.PATH_HOME_SETTING.getKey(), environment.binFile(), "read,readlink");
         addPath(policy, Environment.PATH_HOME_SETTING.getKey(), environment.libFile(), "read,readlink");
         addPath(policy, Environment.PATH_HOME_SETTING.getKey(), environment.libFile(), "read,readlink");
         addPath(policy, Environment.PATH_HOME_SETTING.getKey(), environment.modulesFile(), "read,readlink");
         addPath(policy, Environment.PATH_HOME_SETTING.getKey(), environment.modulesFile(), "read,readlink");
-        addPath(policy, Environment.PATH_PLUGINS_SETTING.getKey(), environment.pluginsFile(), "read,readlink");
+        addPath(policy, Environment.PATH_HOME_SETTING.getKey(), environment.pluginsFile(), "read,readlink");
         addPath(policy, Environment.PATH_CONF_SETTING.getKey(), environment.configFile(), "read,readlink");
         addPath(policy, Environment.PATH_CONF_SETTING.getKey(), environment.configFile(), "read,readlink");
         addPath(policy, Environment.PATH_SCRIPTS_SETTING.getKey(), environment.scriptsFile(), "read,readlink");
         addPath(policy, Environment.PATH_SCRIPTS_SETTING.getKey(), environment.scriptsFile(), "read,readlink");
         // read-write dirs
         // read-write dirs

+ 0 - 1
core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java

@@ -332,7 +332,6 @@ public final class ClusterSettings extends AbstractScopedSettings {
                     Environment.PATH_DATA_SETTING,
                     Environment.PATH_DATA_SETTING,
                     Environment.PATH_HOME_SETTING,
                     Environment.PATH_HOME_SETTING,
                     Environment.PATH_LOGS_SETTING,
                     Environment.PATH_LOGS_SETTING,
-                    Environment.PATH_PLUGINS_SETTING,
                     Environment.PATH_REPO_SETTING,
                     Environment.PATH_REPO_SETTING,
                     Environment.PATH_SCRIPTS_SETTING,
                     Environment.PATH_SCRIPTS_SETTING,
                     Environment.PATH_SHARED_DATA_SETTING,
                     Environment.PATH_SHARED_DATA_SETTING,

+ 1 - 6
core/src/main/java/org/elasticsearch/env/Environment.java

@@ -53,7 +53,6 @@ public class Environment {
     public static final Setting<List<String>> PATH_DATA_SETTING =
     public static final Setting<List<String>> PATH_DATA_SETTING =
         Setting.listSetting("path.data", Collections.emptyList(), Function.identity(), Property.NodeScope);
         Setting.listSetting("path.data", Collections.emptyList(), Function.identity(), Property.NodeScope);
     public static final Setting<String> PATH_LOGS_SETTING = Setting.simpleString("path.logs", Property.NodeScope);
     public static final Setting<String> PATH_LOGS_SETTING = Setting.simpleString("path.logs", Property.NodeScope);
-    public static final Setting<String> PATH_PLUGINS_SETTING = Setting.simpleString("path.plugins", Property.NodeScope);
     public static final Setting<List<String>> PATH_REPO_SETTING =
     public static final Setting<List<String>> PATH_REPO_SETTING =
         Setting.listSetting("path.repo", Collections.emptyList(), Function.identity(), Property.NodeScope);
         Setting.listSetting("path.repo", Collections.emptyList(), Function.identity(), Property.NodeScope);
     public static final Setting<String> PATH_SHARED_DATA_SETTING = Setting.simpleString("path.shared_data", Property.NodeScope);
     public static final Setting<String> PATH_SHARED_DATA_SETTING = Setting.simpleString("path.shared_data", Property.NodeScope);
@@ -128,11 +127,7 @@ public class Environment {
             scriptsFile = configFile.resolve("scripts");
             scriptsFile = configFile.resolve("scripts");
         }
         }
 
 
-        if (PATH_PLUGINS_SETTING.exists(settings)) {
-            pluginsFile = PathUtils.get(cleanPath(PATH_PLUGINS_SETTING.get(settings)));
-        } else {
-            pluginsFile = homeFile.resolve("plugins");
-        }
+        pluginsFile = homeFile.resolve("plugins");
 
 
         List<String> dataPaths = PATH_DATA_SETTING.get(settings);
         List<String> dataPaths = PATH_DATA_SETTING.get(settings);
         if (dataPaths.isEmpty() == false) {
         if (dataPaths.isEmpty() == false) {

+ 3 - 1
core/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java

@@ -304,7 +304,9 @@ class InstallPluginCommand extends SettingCommand {
 
 
                 // be on the safe side: do not rely on that directories are always extracted
                 // be on the safe side: do not rely on that directories are always extracted
                 // before their children (although this makes sense, but is it guaranteed?)
                 // before their children (although this makes sense, but is it guaranteed?)
-                Files.createDirectories(targetFile.getParent());
+                if (!Files.isSymbolicLink(targetFile.getParent())) {
+                    Files.createDirectories(targetFile.getParent());
+                }
                 if (entry.isDirectory() == false) {
                 if (entry.isDirectory() == false) {
                     try (OutputStream out = Files.newOutputStream(targetFile)) {
                     try (OutputStream out = Files.newOutputStream(targetFile)) {
                         int len;
                         int len;

+ 1 - 1
core/src/main/java/org/elasticsearch/plugins/RemovePluginCommand.java

@@ -71,7 +71,7 @@ class RemovePluginCommand extends SettingCommand {
 
 
         Path pluginDir = env.pluginsFile().resolve(pluginName);
         Path pluginDir = env.pluginsFile().resolve(pluginName);
         if (Files.exists(pluginDir) == false) {
         if (Files.exists(pluginDir) == false) {
-            throw new UserError(ExitCodes.USAGE, "Plugin " + pluginName + " not found. Run 'plugin list' to get list of installed plugins.");
+            throw new UserError(ExitCodes.USAGE, "plugin " + pluginName + " not found; run 'elasticsearch-plugin list' to get list of installed plugins");
         }
         }
 
 
         List<Path> pluginPaths = new ArrayList<>();
         List<Path> pluginPaths = new ArrayList<>();

+ 0 - 3
core/src/main/java/org/elasticsearch/tribe/TribeService.java

@@ -220,9 +220,6 @@ public class TribeService extends AbstractLifecycleComponent<TribeService> {
         if (Environment.PATH_CONF_SETTING.exists(globalSettings)) {
         if (Environment.PATH_CONF_SETTING.exists(globalSettings)) {
             sb.put(Environment.PATH_CONF_SETTING.getKey(), Environment.PATH_CONF_SETTING.get(globalSettings));
             sb.put(Environment.PATH_CONF_SETTING.getKey(), Environment.PATH_CONF_SETTING.get(globalSettings));
         }
         }
-        if (Environment.PATH_PLUGINS_SETTING.exists(globalSettings)) {
-            sb.put(Environment.PATH_PLUGINS_SETTING.getKey(), Environment.PATH_PLUGINS_SETTING.get(globalSettings));
-        }
         if (Environment.PATH_LOGS_SETTING.exists(globalSettings)) {
         if (Environment.PATH_LOGS_SETTING.exists(globalSettings)) {
             sb.put(Environment.PATH_LOGS_SETTING.getKey(), Environment.PATH_LOGS_SETTING.get(globalSettings));
             sb.put(Environment.PATH_LOGS_SETTING.getKey(), Environment.PATH_LOGS_SETTING.get(globalSettings));
         }
         }

+ 0 - 2
core/src/test/java/org/elasticsearch/tribe/TribeServiceTests.java

@@ -43,13 +43,11 @@ public class TribeServiceTests extends ESTestCase {
             .put("node.name", "nodename")
             .put("node.name", "nodename")
             .put("path.home", "some/path")
             .put("path.home", "some/path")
             .put("path.conf", "conf/path")
             .put("path.conf", "conf/path")
-            .put("path.plugins", "plugins/path")
             .put("path.scripts", "scripts/path")
             .put("path.scripts", "scripts/path")
             .put("path.logs", "logs/path").build();
             .put("path.logs", "logs/path").build();
         Settings clientSettings = TribeService.buildClientSettings("tribe1", globalSettings, Settings.EMPTY);
         Settings clientSettings = TribeService.buildClientSettings("tribe1", globalSettings, Settings.EMPTY);
         assertEquals("some/path", clientSettings.get("path.home"));
         assertEquals("some/path", clientSettings.get("path.home"));
         assertEquals("conf/path", clientSettings.get("path.conf"));
         assertEquals("conf/path", clientSettings.get("path.conf"));
-        assertEquals("plugins/path", clientSettings.get("path.plugins"));
         assertEquals("scripts/path", clientSettings.get("path.scripts"));
         assertEquals("scripts/path", clientSettings.get("path.scripts"));
         assertEquals("logs/path", clientSettings.get("path.logs"));
         assertEquals("logs/path", clientSettings.get("path.logs"));
 
 

+ 1 - 12
docs/plugins/plugin-script.asciidoc

@@ -180,18 +180,7 @@ set ES_JAVA_OPTS="-DproxyHost=host_name -DproxyPort=port_number"
 bin/elasticsearch-plugin install analysis-icu
 bin/elasticsearch-plugin install analysis-icu
 -----------------------------------
 -----------------------------------
 
 
-=== Settings related to plugins
-
-[float]
-=== Custom plugins directory
-
-The `plugins` directory can be changed from the default by adding the
-following to the `elasticsearch.yml` config file:
-
-[source,yml]
----------------------
-path.plugins: /path/to/custom/plugins/dir
----------------------
+=== Plugins directory
 
 
 The default location of the `plugins` directory depends on which package you install:
 The default location of the `plugins` directory depends on which package you install:
 
 

+ 5 - 0
docs/reference/migration/migrate_5_0/plugins.asciidoc

@@ -112,3 +112,8 @@ Previously, Java system properties could be passed to the plugin
 command by passing `-D` style arguments directly to the plugin script.
 command by passing `-D` style arguments directly to the plugin script.
 This is no longer permitted and such system properties must be passed
 This is no longer permitted and such system properties must be passed
 via ES_JAVA_OPTS.
 via ES_JAVA_OPTS.
+
+==== Custom plugins path
+
+The ability to specify a custom plugins path via `path.plugins` has
+been removed.

+ 0 - 1
docs/reference/modules/tribe.asciidoc

@@ -87,7 +87,6 @@ configuration options are passed down from the tribe node to each node client:
 * `transport.publish_host`
 * `transport.publish_host`
 * `path.home`
 * `path.home`
 * `path.conf`
 * `path.conf`
-* `path.plugins`
 * `path.logs`
 * `path.logs`
 * `path.scripts`
 * `path.scripts`
 * `shield.*`
 * `shield.*`

+ 0 - 1
docs/reference/setup/install/deb.asciidoc

@@ -174,7 +174,6 @@ locations for a Debian-based system:
 | plugins
 | plugins
   | Plugin files location. Each plugin will be contained in a subdirectory.
   | Plugin files location. Each plugin will be contained in a subdirectory.
   | /usr/share/elasticsearch/plugins
   | /usr/share/elasticsearch/plugins
-  | path.plugins
 
 
 | repo
 | repo
   | Shared file system repository locations. Can hold multiple locations. A file system repository can be placed in to any subdirectory of any directory specified here.
   | Shared file system repository locations. Can hold multiple locations. A file system repository can be placed in to any subdirectory of any directory specified here.

+ 0 - 1
docs/reference/setup/install/rpm.asciidoc

@@ -160,7 +160,6 @@ locations for an RPM-based system:
 | plugins
 | plugins
   | Plugin files location. Each plugin will be contained in a subdirectory.
   | Plugin files location. Each plugin will be contained in a subdirectory.
   | /usr/share/elasticsearch/plugins
   | /usr/share/elasticsearch/plugins
-  | path.plugins
 
 
 | repo
 | repo
   | Shared file system repository locations. Can hold multiple locations. A file system repository can be placed in to any subdirectory of any directory specified here.
   | Shared file system repository locations. Can hold multiple locations. A file system repository can be placed in to any subdirectory of any directory specified here.

+ 0 - 1
docs/reference/setup/install/windows.asciidoc

@@ -228,7 +228,6 @@ directory so that you do not delete important data later on.
 | plugins
 | plugins
   | Plugin files location. Each plugin will be contained in a subdirectory.
   | Plugin files location. Each plugin will be contained in a subdirectory.
   | %ES_HOME%\plugins
   | %ES_HOME%\plugins
-  | path.plugins
 
 
 | repo
 | repo
   | Shared file system repository locations. Can hold multiple locations. A file system repository can be placed in to any subdirectory of any directory specified here.
   | Shared file system repository locations. Can hold multiple locations. A file system repository can be placed in to any subdirectory of any directory specified here.

+ 0 - 1
docs/reference/setup/install/zip-targz.asciidoc

@@ -147,7 +147,6 @@ directory so that you do not delete important data later on.
 | plugins
 | plugins
   | Plugin files location. Each plugin will be contained in a subdirectory.
   | Plugin files location. Each plugin will be contained in a subdirectory.
   | $ES_HOME/plugins
   | $ES_HOME/plugins
-  | path.plugins
 
 
 | repo
 | repo
   | Shared file system repository locations. Can hold multiple locations. A file system repository can be placed in to any subdirectory of any directory specified here.
   | Shared file system repository locations. Can hold multiple locations. A file system repository can be placed in to any subdirectory of any directory specified here.

+ 0 - 1
qa/evil-tests/src/test/java/org/elasticsearch/bootstrap/EvilSecurityTests.java

@@ -77,7 +77,6 @@ public class EvilSecurityTests extends ESTestCase {
         settingsBuilder.put(Environment.PATH_HOME_SETTING.getKey(), esHome.resolve("home").toString());
         settingsBuilder.put(Environment.PATH_HOME_SETTING.getKey(), esHome.resolve("home").toString());
         settingsBuilder.put(Environment.PATH_CONF_SETTING.getKey(), esHome.resolve("conf").toString());
         settingsBuilder.put(Environment.PATH_CONF_SETTING.getKey(), esHome.resolve("conf").toString());
         settingsBuilder.put(Environment.PATH_SCRIPTS_SETTING.getKey(), esHome.resolve("scripts").toString());
         settingsBuilder.put(Environment.PATH_SCRIPTS_SETTING.getKey(), esHome.resolve("scripts").toString());
-        settingsBuilder.put(Environment.PATH_PLUGINS_SETTING.getKey(), esHome.resolve("plugins").toString());
         settingsBuilder.putArray(Environment.PATH_DATA_SETTING.getKey(), esHome.resolve("data1").toString(), esHome.resolve("data2").toString());
         settingsBuilder.putArray(Environment.PATH_DATA_SETTING.getKey(), esHome.resolve("data1").toString(), esHome.resolve("data2").toString());
         settingsBuilder.put(Environment.PATH_SHARED_DATA_SETTING.getKey(), esHome.resolve("custom").toString());
         settingsBuilder.put(Environment.PATH_SHARED_DATA_SETTING.getKey(), esHome.resolve("custom").toString());
         settingsBuilder.put(Environment.PATH_LOGS_SETTING.getKey(), esHome.resolve("logs").toString());
         settingsBuilder.put(Environment.PATH_LOGS_SETTING.getKey(), esHome.resolve("logs").toString());

+ 1 - 1
qa/evil-tests/src/test/java/org/elasticsearch/plugins/RemovePluginCommandTests.java

@@ -73,7 +73,7 @@ public class RemovePluginCommandTests extends ESTestCase {
 
 
     public void testMissing() throws Exception {
     public void testMissing() throws Exception {
         UserError e = expectThrows(UserError.class, () -> removePlugin("dne", home));
         UserError e = expectThrows(UserError.class, () -> removePlugin("dne", home));
-        assertTrue(e.getMessage(), e.getMessage().contains("Plugin dne not found"));
+        assertTrue(e.getMessage(), e.getMessage().contains("plugin dne not found"));
         assertRemoveCleaned(env);
         assertRemoveCleaned(env);
     }
     }
 
 

+ 9 - 8
qa/vagrant/src/test/resources/packaging/scripts/module_and_plugin_test_cases.bash

@@ -113,25 +113,26 @@ fi
     fi
     fi
 }
 }
 
 
-@test "[$GROUP] install jvm-example plugin with a custom path.plugins" {
+@test "[$GROUP] install jvm-example plugin with a symlinked plugins path" {
     # Clean up after the last time this test was run
     # Clean up after the last time this test was run
     rm -rf /tmp/plugins.*
     rm -rf /tmp/plugins.*
+    rm -rf /tmp/old_plugins.*
 
 
-    local oldPlugins="$ESPLUGINS"
-    export ESPLUGINS=$(mktemp -d -t 'plugins.XXXX')
-
-    # Modify the path.plugins setting in configuration file
-    echo "path.plugins: $ESPLUGINS" >> "$ESCONFIG/elasticsearch.yml"
-    chown -R elasticsearch:elasticsearch "$ESPLUGINS"
+    rm -rf "$ESPLUGINS"
+    local es_plugins=$(mktemp -d -t 'plugins.XXXX')
+    chown -R elasticsearch:elasticsearch "$es_plugins"
+    ln -s "$es_plugins" "$ESPLUGINS"
 
 
     install_jvm_example
     install_jvm_example
     start_elasticsearch_service
     start_elasticsearch_service
-    # check that configuration was actually picked up
+    # check that symlinked plugin was actually picked up
     curl -s localhost:9200/_cat/configured_example | sed 's/ *$//' > /tmp/installed
     curl -s localhost:9200/_cat/configured_example | sed 's/ *$//' > /tmp/installed
     echo "foo" > /tmp/expected
     echo "foo" > /tmp/expected
     diff /tmp/installed /tmp/expected
     diff /tmp/installed /tmp/expected
     stop_elasticsearch_service
     stop_elasticsearch_service
     remove_jvm_example
     remove_jvm_example
+
+    unlink "$ESPLUGINS"
 }
 }
 
 
 @test "[$GROUP] install jvm-example plugin with a custom CONFIG_DIR" {
 @test "[$GROUP] install jvm-example plugin with a custom CONFIG_DIR" {