Skip to content

Commit

Permalink
Revert "Surface ES startup errors to the Rally CLI console (#1476)" (#…
Browse files Browse the repository at this point in the history
…1550)

it definitely appears that any capturing of stdout or stderr to a pipe is causing the deadlock.
  • Loading branch information
b-deam authored Jul 28, 2022
1 parent 6b3f9dd commit 6eaf621
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
23 changes: 13 additions & 10 deletions esrally/mechanic/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
import os
import shlex
import subprocess
from textwrap import indent

import psutil

from esrally import exceptions, telemetry, time
from esrally.mechanic import cluster, java_resolver
from esrally.utils import console, io, opts, process
from esrally.utils import io, opts, process


class DockerLauncher:
Expand Down Expand Up @@ -200,9 +199,13 @@ def _set_env(self, env, k, v, separator=" ", prepend=False):
@staticmethod
def _run_subprocess(command_line, env):
command_line_args = shlex.split(command_line)
subprocess.run(
command_line_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, start_new_session=True, check=True, text=True
)

with subprocess.Popen(
command_line_args, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, env=env, start_new_session=True
) as command_line_process:
# wait for it to finish
command_line_process.wait()
return command_line_process.returncode

@staticmethod
def _start_process(binary_path, env):
Expand All @@ -212,11 +215,11 @@ def _start_process(binary_path, env):
cmd = [io.escape_path(os.path.join(".", "bin", "elasticsearch"))]
pid_path = io.escape_path(os.path.join(".", "pid"))
cmd.extend(["-d", "-p", pid_path])
try:
ProcessLauncher._run_subprocess(command_line=" ".join(cmd), env=env)
except subprocess.CalledProcessError as e:
console.error("Daemon startup failed with exit code [%s]. STDERR:\n\n%s\n" % (e.returncode, indent(e.stderr, "\t")))
raise e
ret = ProcessLauncher._run_subprocess(command_line=" ".join(cmd), env=env)
if ret != 0:
msg = "Daemon startup failed with exit code [{}]".format(ret)
logging.error(msg)
raise exceptions.LaunchError(msg)

return wait_for_pidfile(pid_path)

Expand Down
2 changes: 1 addition & 1 deletion tests/driver/runner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6215,7 +6215,7 @@ async def test_adds_request_timings(self):
assert len(timings) == 3

assert timings[0]["operation"] == "initial-call"
assert timings[0]["service_time"] == pytest.approx(0.1, abs=0.15)
assert timings[0]["service_time"] == pytest.approx(0.1, abs=0.1)

assert timings[1]["operation"] == "stream-a"
assert timings[1]["service_time"] == pytest.approx(0.2, abs=0.1)
Expand Down
1 change: 0 additions & 1 deletion tests/mechanic/launcher_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def __init__(self, *args, **kwargs):
# mocking them as their optional functionality is disabled.
self.returncode = 1
self.stdout = io.StringIO()
self.args = None

def communicate(self, input=None, timeout=None):
return [b"", b""]
Expand Down

0 comments on commit 6eaf621

Please sign in to comment.