From 2e9e555269cd58429fef507f178c6995e3d6f609 Mon Sep 17 00:00:00 2001 From: Andras Palinkas Date: Mon, 25 Jan 2021 12:24:03 -0500 Subject: [PATCH] SQL: Fix elasticsearch-sql-cli under docker (#67737) (#67919) Calling `./bin/elasticsearch-sql-cli http://localhost:9200`under docker failed with `ERROR: E is not a recognized option` error message. The root cause is that under docker the environmental variables are automatically appended to the arguments of the sql cli. `"$@"` will contain `-Evar=value` strings added by the `elasticsearch-env` (line 122). This change uses the original argument list (saves it before it is modified) when the sql cli is called. Fixes #57744 --- .../java/org/elasticsearch/packaging/test/SqlCliTests.java | 2 -- x-pack/plugin/sql/src/main/bin/elasticsearch-sql-cli | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qa/os/src/test/java/org/elasticsearch/packaging/test/SqlCliTests.java b/qa/os/src/test/java/org/elasticsearch/packaging/test/SqlCliTests.java index 058279cfac45f..f681cb9df2a09 100644 --- a/qa/os/src/test/java/org/elasticsearch/packaging/test/SqlCliTests.java +++ b/qa/os/src/test/java/org/elasticsearch/packaging/test/SqlCliTests.java @@ -24,14 +24,12 @@ import org.junit.Before; import static org.hamcrest.CoreMatchers.containsString; -import static org.junit.Assume.assumeFalse; import static org.junit.Assume.assumeTrue; public class SqlCliTests extends PackagingTestCase { @Before public void filterDistros() { assumeTrue("only default distro", distribution.flavor == Distribution.Flavor.DEFAULT); - assumeFalse("no docker", distribution.isDocker()); } public void test010Install() throws Exception { diff --git a/x-pack/plugin/sql/src/main/bin/elasticsearch-sql-cli b/x-pack/plugin/sql/src/main/bin/elasticsearch-sql-cli index 4bafba9bda3a8..4d145afd4b100 100755 --- a/x-pack/plugin/sql/src/main/bin/elasticsearch-sql-cli +++ b/x-pack/plugin/sql/src/main/bin/elasticsearch-sql-cli @@ -4,6 +4,8 @@ # or more contributor license agreements. Licensed under the Elastic License; # you may not use this file except in compliance with the Elastic License. +CLI_PARAMETERS="$@" + source "`dirname "$0"`"/elasticsearch-env source "$ES_HOME"/bin/x-pack-env @@ -14,4 +16,4 @@ exec \ "$JAVA" \ "$XSHARE" \ -jar "$CLI_JAR" \ - "$@" + $CLI_PARAMETERS