-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Description
Elasticsearch version (bin/elasticsearch --version): 5.6.10
Plugins installed: custom/user-defined plugins
JVM version (java -version): 1.8.0_265
OS version (uname -a if on a Unix-like system): Windows Server 2019
Description of the problem including expected versus actual behavior:
I am installing a custom plugin for ES 5.6.10 by wrapping elasticsearch-plugin.bat command in a .NET Process object with and plugin name as arguments.
This process returns exit code 0 before the plugin installation completes which creates problems when the plugin installation fails. This could be due to the below line in elasticsearch-plugin.bat not returning %%ERRORLEVEL%% during exit.
%JAVA% %ES_JAVA_OPTS% !path_props! -cp "%ES_HOME%/lib/*;" "org.elasticsearch.plugins.PluginCli" !args!
Ideally, the plugin batch script should return a non-zero exit-code if a plugin fails installation.
Steps to reproduce:
Please include a minimal but complete recreation of the problem,
including (e.g.) index creation, mappings, settings, query etc. The easier
you make for us to reproduce it, the more likely that somebody will take the
time to look at it.
- Create a .NET ProcessInfo with following params:
a. local plugin file name and command as argument. Sample argument string -> --install file:///c:/customplugins/mycustom-plugin1.zip
b. fileName should be path to elasticsearch-plugin.bat Sample ->c:\elasticsearch\bin\elasticsearch-plugin.bat
c. UseShellExecute = false
d. RedirectStandardError = true
e. RedirectStandardOutput = true
f. Verb = "runas" - Add event handlers for logging standard log output and error output.
- Invoke Process.Start with the above ProcessInfo as argument -> process.start(processInfo). Sample usage can be found here
Provide logs (if relevant):
2020-10-16 00:59:40.7401417 | Executing program: c:\elasticsearch\bin\elasticsearch-plugin.bat, working directory: , args: install file:///c:/elasticsearch/customplugins/custom-allocation-plugin.zip , maximum execution time of 00:02:00
2020-10-16 00:59:40.7450299 | START: c:\elasticsearch\bin\elasticsearch-plugin.bat ID:cfdb87cc-7870-4eab-9027-9712e09804e5
2020-10-16 00:59:42.1989771 | -> Downloading file:///c:/elasticsearch/customplugins/custom-allocation-plugin.zip
[=================> ] 37%áá
[====================================> ] 75%áá
[================================================>] 99%áá
[=================================================] 100%áá
2020-10-16 00:59:42.2236910 | STOP: c:\elasticsearch\bin\elasticsearch-plugin.bat ID:cfdb87cc-7870-4eab-9027-9712e09804e5. Duration: 00:00:01.4786386. ExitCode: 0
2020-10-16 00:59:42.4582086 | Exception in thread "main" java.nio.file.AccessDeniedException: c:\elasticsearch\plugins\.installing-4958296876653745062 -> c:\elasticsearch\plugins\custom-allocation-plugin
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:301)
at sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:287)
at java.nio.file.Files.move(Files.java:1395)
at org.elasticsearch.plugins.InstallPluginCommand.install(InstallPluginCommand.java:587)
at org.elasticsearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:218)
at org.elasticsearch.plugins.InstallPluginCommand.execute(InstallPluginCommand.java:202)
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:70)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134)
at org.elasticsearch.cli.MultiCommand.execute(MultiCommand.java:69)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134)
at org.elasticsearch.cli.Command.main(Command.java:90)
at org.elasticsearch.plugins.PluginCli.main(PluginCli.java:47)
Suppressed: java.io.IOException: Could not remove the following files (in the order of attempts):
c:\elasticsearch\plugins\.installing-4958296876653745062: java.nio.file.DirectoryNotEmptyException: c:\elasticsearch\plugins\.installing-4958296876653745062
at org.apache.lucene.util.IOUtils.rm(IOUtils.java:329)
at org.elasticsearch.plugins.InstallPluginCommand.install(InstallPluginCommand.java:610)
... 8 more
NOTE: The exception is thrown after the "STOP' log and the exitCode returned in "0" even though an exception occurred.