Skip to content

Fix passing positional args to ES in Docker #88502

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

Merged
merged 2 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion distribution/docker/src/docker/bin/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ fi

# Signal forwarding and child reaping is handled by `tini`, which is the
# actual entrypoint of the container
exec /usr/share/elasticsearch/bin/elasticsearch $POSITIONAL_PARAMETERS <<<"$KEYSTORE_PASSWORD"
exec /usr/share/elasticsearch/bin/elasticsearch "$@" $POSITIONAL_PARAMETERS <<<"$KEYSTORE_PASSWORD"
5 changes: 5 additions & 0 deletions docs/changelog/88502.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 88502
summary: Fix passing positional args to ES in Docker
area: Packaging
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,18 @@ public void test170DefaultShellIsBash() {
}
}

/**
* Ensure that it is possible to apply CLI options when running the image.
*/
public void test171AdditionalCliOptionsAreForwarded() throws Exception {
runContainer(distribution(), builder().runArgs("bin/elasticsearch", "-Ecluster.name=kimchy").envVar("ELASTIC_PASSWORD", PASSWORD));
waitForElasticsearch(installation, "elastic", PASSWORD);

final JsonNode node = getJson("/", "elastic", PASSWORD, ServerUtils.getCaCert(installation));

assertThat(node.get("cluster_name").textValue(), equalTo("kimchy"));
}

/**
* Check that the UBI images has the correct license information in the correct place.
*/
Expand Down Expand Up @@ -1193,7 +1205,7 @@ private List<String> listPlugins() {
/**
* Check that readiness listener works
*/
public void testReadiness001() throws Exception {
public void test500Readiness() throws Exception {
assertFalse(readinessProbe(9399));
// Disabling security so we wait for green
installation = runContainer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class DockerRun {
private Integer uid;
private Integer gid;
private final List<String> extraArgs = new ArrayList<>();
private final List<String> runArgs = new ArrayList<>();
private String memory = "2g"; // default to 2g memory limit

private DockerRun() {}
Expand Down Expand Up @@ -95,6 +96,11 @@ public DockerRun extraArgs(String... args) {
return this;
}

public DockerRun runArgs(String... args) {
Collections.addAll(this.runArgs, args);
return this;
}

String build() {
final List<String> cmd = new ArrayList<>();

Expand Down Expand Up @@ -144,6 +150,8 @@ String build() {
// Image name
cmd.add(getImageName(distribution));

cmd.addAll(this.runArgs);

return String.join(" ", cmd);
}

Expand Down