Skip to content
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

elasticsearch-plugin.bat script returns exit code 0 during errors in ES 5.6 #64441

Closed
vamuzumd opened this issue Oct 30, 2020 · 2 comments
Closed
Labels
>bug :Core/Infra/Plugins Plugin API and infrastructure Team:Core/Infra Meta label for core/infra team

Comments

@vamuzumd
Copy link
Contributor

vamuzumd commented Oct 30, 2020

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.

  1. 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"
  2. Add event handlers for logging standard log output and error output.
  3. 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.

@vamuzumd vamuzumd added >bug needs:triage Requires assignment of a team area label labels Oct 30, 2020
@vamuzumd vamuzumd changed the title Plugin batch script returns exit code 0 during errors in ES 5.6 elasticsearch-plugin.bat script returns exit code 0 during errors in ES 5.6 Oct 30, 2020
@dakrone dakrone added :Core/Infra/Plugins Plugin API and infrastructure and removed needs:triage Requires assignment of a team area label labels Oct 30, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (:Core/Infra/Plugins)

@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Oct 30, 2020
@rjernst
Copy link
Member

rjernst commented Oct 30, 2020

This has already been fixed since 6.7.0, see #29583.

@rjernst rjernst closed this as completed Oct 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Core/Infra/Plugins Plugin API and infrastructure Team:Core/Infra Meta label for core/infra team
Projects
None yet
Development

No branches or pull requests

4 participants