Skip to content

Remove special handling for ingest plugins #36967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,6 @@ void execute(Terminal terminal, String pluginId, boolean isBatch, Environment en
throw new UserException(ExitCodes.USAGE, "plugin id is required");
}

if ("ingest-geoip".equals(pluginId) || "ingest-user-agent".equals(pluginId)) {
throw new UserException(
ExitCodes.OK,
"[" + pluginId + "] is no longer a plugin but instead a module packaged with this distribution of Elasticsearch");
}

if ("x-pack".equals(pluginId)) {
handleInstallXPack(buildFlavor());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,6 @@ void execute(Terminal terminal, Environment env, String pluginName, boolean purg
*/
if ((!Files.exists(pluginDir) && !Files.exists(pluginConfigDir) && !Files.exists(removing))
|| (!Files.exists(pluginDir) && Files.exists(pluginConfigDir) && !purge)) {

/*
* This is special case handling for ingest-geoip and ingest-user-agent since they are modules now but could have been installed
* from a previous version when they were plugins.
*/
if ("ingest-geoip".equals(pluginName) || "ingest-user-agent".equals(pluginName)) {
throw new UserException(
ExitCodes.OK,
"[" + pluginName + "] is no longer a plugin but instead a module packaged with this distribution of Elasticsearch");
}

final String message = String.format(
Locale.ROOT, "plugin [%s] not found; run 'elasticsearch-plugin list' to get list of installed plugins", pluginName);
throw new UserException(ExitCodes.CONFIG, message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -757,27 +757,6 @@ protected boolean addShutdownHook() {
}
}

public void testInstallIngestGeoIp() throws IOException {
runInstallIngestGeoIpOrIngestUserAgentTest("ingest-geoip");
}

public void testInstallIngestUserAgent() throws IOException {
runInstallIngestGeoIpOrIngestUserAgentTest("ingest-user-agent");
}

private void runInstallIngestGeoIpOrIngestUserAgentTest(final String pluginId) throws IOException {
assert "ingest-geoip".equals(pluginId) || "ingest-user-agent".equals(pluginId) : pluginId;
final Environment environment = createEnv(fs, temp).v2();
final UserException exception =
expectThrows(UserException.class, () -> new InstallPluginCommand().execute(terminal, pluginId, false, environment));
assertThat(exception.exitCode, equalTo(ExitCodes.OK));
assertThat(
exception,
hasToString(containsString(
"[" + pluginId + "] is no longer a plugin but instead a module packaged with this distribution of Elasticsearch")));

}

public void testInstallXPack() throws IOException {
runInstallXPackTest(Build.Flavor.DEFAULT, UserException.class, "this distribution of Elasticsearch contains X-Pack by default");
runInstallXPackTest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.elasticsearch.env.TestEnvironment;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.VersionUtils;
import org.hamcrest.Matchers;
import org.junit.Before;

import java.io.BufferedReader;
Expand Down Expand Up @@ -252,57 +251,6 @@ public void testMissingPluginName() throws Exception {
assertEquals("plugin name is required", e.getMessage());
}

/**
* The ingest-geoip plugin receives special handling because we have re-packaged it as a module; this test ensures that we are still
* able to uninstall an old installation of ingest-geoip.
*
* @throws Exception if an exception is thrown creating or removing the plugin
*/
public void testRemoveIngestGeoIp() throws Exception {
runTestRemoveIngestGeoIpOrIngestUserAgent("ingest-geoip");
}

/**
* The ingest-user-agent plugin receives special handling because we have re-packaged it as a module; this test ensures that we are
* still able to uninstall an old installation of ingest-user-agent.
*
* @throws Exception if an exception is thrown creating or removing the plugin
*/
public void testRemoveIngestUserAgent() throws Exception {
runTestRemoveIngestGeoIpOrIngestUserAgent("ingest-user-agent");
}

private void runTestRemoveIngestGeoIpOrIngestUserAgent(final String name) throws Exception {
assert "ingest-geoip".equals(name) || "ingest-user-agent".equals(name) : name;
createPlugin(
name,
VersionUtils.randomVersionBetween(
random(),
Version.CURRENT.minimumIndexCompatibilityVersion(),
Version.V_6_6_0));
removePlugin(name, home, randomBoolean());
assertThat(Files.exists(env.pluginsFile().resolve(name)), equalTo(false));
assertRemoveCleaned(env);
}

public void testRemoveIngestGeoIpWhenNotInstalled() {
runTestRemoveIngestGeoIpOrIngestUserAgentWhenNotInstalled("ingest-geoip");
}

public void testRemoveIngestUserAgentWhenNotInstalled() {
runTestRemoveIngestGeoIpOrIngestUserAgentWhenNotInstalled("ingest-user-agent");
}

private void runTestRemoveIngestGeoIpOrIngestUserAgentWhenNotInstalled(final String name) {
assert "ingest-geoip".equals(name) || "ingest-user-agent".equals(name) : name;
final UserException e = expectThrows(UserException.class, () -> removePlugin(name, home, randomBoolean()));
assertThat(e.exitCode, equalTo(ExitCodes.OK));
assertThat(
e,
hasToString(Matchers.containsString(
"[" + name + "] is no longer a plugin but instead a module packaged with this distribution of Elasticsearch")));
}

public void testRemoveWhenRemovingMarker() throws Exception {
createPlugin("fake");
Files.createFile(env.pluginsFile().resolve("fake").resolve("plugin.jar"));
Expand Down