Skip to content

Commit 8cb3d18

Browse files
Revert "Improve error message for installing plugin (#28298)"
This reverts commit 0cc1ffd The reason is that Windows test are failing, because of the incorrect path for the plugin
1 parent cf60e93 commit 8cb3d18

File tree

3 files changed

+10
-20
lines changed

3 files changed

+10
-20
lines changed

distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
import java.nio.file.FileVisitResult;
5454
import java.nio.file.Files;
5555
import java.nio.file.Path;
56-
import java.nio.file.Paths;
5756
import java.nio.file.SimpleFileVisitor;
5857
import java.nio.file.StandardCopyOption;
5958
import java.nio.file.attribute.BasicFileAttributes;
@@ -219,25 +218,25 @@ void execute(Terminal terminal, String pluginId, boolean isBatch, Environment en
219218
throw new UserException(ExitCodes.USAGE, "plugin id is required");
220219
}
221220

222-
Path pluginZip = download(terminal, pluginId, env.tmpFile(), env.pluginsFile());
221+
Path pluginZip = download(terminal, pluginId, env.tmpFile());
223222
Path extractedZip = unzip(pluginZip, env.pluginsFile());
224223
install(terminal, isBatch, extractedZip, env);
225224
}
226225

227226
/** Downloads the plugin and returns the file it was downloaded to. */
228-
private Path download(Terminal terminal, String pluginId, Path tmpDir, Path pluginsDir) throws Exception {
227+
private Path download(Terminal terminal, String pluginId, Path tmpDir) throws Exception {
229228
if (OFFICIAL_PLUGINS.contains(pluginId)) {
230229
final String url = getElasticUrl(terminal, getStagingHash(), Version.CURRENT, pluginId, Platforms.PLATFORM_NAME);
231230
terminal.println("-> Downloading " + pluginId + " from elastic");
232-
return downloadZipAndChecksum(terminal, url, tmpDir, pluginsDir, false);
231+
return downloadZipAndChecksum(terminal, url, tmpDir, false);
233232
}
234233

235234
// now try as maven coordinates, a valid URL would only have a colon and slash
236235
String[] coordinates = pluginId.split(":");
237236
if (coordinates.length == 3 && pluginId.contains("/") == false && pluginId.startsWith("file:") == false) {
238237
String mavenUrl = getMavenUrl(terminal, coordinates, Platforms.PLATFORM_NAME);
239238
terminal.println("-> Downloading " + pluginId + " from maven central");
240-
return downloadZipAndChecksum(terminal, mavenUrl, tmpDir, pluginsDir, true);
239+
return downloadZipAndChecksum(terminal, mavenUrl, tmpDir, true);
241240
}
242241

243242
// fall back to plain old URL
@@ -251,7 +250,7 @@ private Path download(Terminal terminal, String pluginId, Path tmpDir, Path plug
251250
throw new UserException(ExitCodes.USAGE, msg);
252251
}
253252
terminal.println("-> Downloading " + URLDecoder.decode(pluginId, "UTF-8"));
254-
return downloadZip(terminal, pluginId, tmpDir, pluginsDir);
253+
return downloadZip(terminal, pluginId, tmpDir);
255254
}
256255

257256
// pkg private so tests can override
@@ -325,17 +324,9 @@ private List<String> checkMisspelledPlugin(String pluginId) {
325324
/** Downloads a zip from the url, into a temp file under the given temp dir. */
326325
// pkg private for tests
327326
@SuppressForbidden(reason = "We use getInputStream to download plugins")
328-
Path downloadZip(Terminal terminal, String urlString, Path tmpDir, Path pluginsDir) throws IOException {
327+
Path downloadZip(Terminal terminal, String urlString, Path tmpDir) throws IOException {
329328
terminal.println(VERBOSE, "Retrieving zip from " + urlString);
330329
URL url = new URL(urlString);
331-
if (url.getProtocol().equals("file")) {
332-
Path pluginsFile = Paths.get(url.getFile());
333-
if (pluginsFile.startsWith(pluginsDir)) {
334-
throw new IllegalStateException("Installation failed! " +
335-
"Make sure the plugins directory [" + pluginsDir + "] can not contain the plugin distribution [" +
336-
pluginsFile + "]; move the distribution to an alternate location!");
337-
}
338-
}
339330
Path zip = Files.createTempFile(tmpDir, null, ".zip");
340331
URLConnection urlConnection = url.openConnection();
341332
urlConnection.addRequestProperty("User-Agent", "elasticsearch-plugin-installer");
@@ -384,9 +375,8 @@ public void onProgress(int percent) {
384375
/** Downloads a zip from the url, as well as a SHA512 (or SHA1) checksum, and checks the checksum. */
385376
// pkg private for tests
386377
@SuppressForbidden(reason = "We use openStream to download plugins")
387-
private Path downloadZipAndChecksum(Terminal terminal, String urlString, Path tmpDir, Path pluginsDir, boolean allowSha1)
388-
throws Exception {
389-
Path zip = downloadZip(terminal, urlString, tmpDir, pluginsDir);
378+
private Path downloadZipAndChecksum(Terminal terminal, String urlString, Path tmpDir, boolean allowSha1) throws Exception {
379+
Path zip = downloadZip(terminal, urlString, tmpDir);
390380
pathsToDeleteOnShutdown.add(zip);
391381
String checksumUrlString = urlString + ".sha512";
392382
URL checksumUrl = openUrl(checksumUrlString);

distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/InstallPluginCommandTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ void assertInstallPluginFromUrl(String pluginId, String name, String url, String
981981
Path pluginZip = createPlugin(name, pluginDir);
982982
InstallPluginCommand command = new InstallPluginCommand() {
983983
@Override
984-
Path downloadZip(Terminal terminal, String urlString, Path tmpDir, Path pluginsDir) throws IOException {
984+
Path downloadZip(Terminal terminal, String urlString, Path tmpDir) throws IOException {
985985
assertEquals(url, urlString);
986986
Path downloadedPath = tmpDir.resolve("downloaded.zip");
987987
Files.copy(pluginZip, downloadedPath);

server/src/main/java/org/elasticsearch/plugins/PluginsService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ public String name() {
328328
public Collection<Bundle> bundles() {
329329
return bundles;
330330
}
331-
331+
332332
}
333333

334334
/**

0 commit comments

Comments
 (0)