Skip to content

Commit

Permalink
SQL: Fix elasticsearch-sql-cli under docker (#67737) (#67919)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Andras Palinkas authored Jan 25, 2021
1 parent 770da00 commit 2e9e555
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugin/sql/src/main/bin/elasticsearch-sql-cli
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -14,4 +16,4 @@ exec \
"$JAVA" \
"$XSHARE" \
-jar "$CLI_JAR" \
"$@"
$CLI_PARAMETERS

0 comments on commit 2e9e555

Please sign in to comment.