Skip to content

Commit

Permalink
fix(cli): make quickstart docker compose up command more robust (#8929)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsheth2 authored Oct 4, 2023
1 parent 9deb7be commit 419b8a7
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions metadata-ingestion/src/datahub/cli/docker_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def detect_quickstart_arch(arch: Optional[str]) -> Architectures:
return quickstart_arch


@docker.command()
@docker.command() # noqa: C901
@click.option(
"--version",
type=str,
Expand Down Expand Up @@ -588,7 +588,7 @@ def detect_quickstart_arch(arch: Optional[str]) -> Architectures:
"arch",
]
)
def quickstart(
def quickstart( # noqa: C901
version: Optional[str],
build_locally: bool,
pull_images: bool,
Expand Down Expand Up @@ -755,14 +755,21 @@ def quickstart(
up_attempts += 1

logger.debug(f"Executing docker compose up command, attempt #{up_attempts}")
up_process = subprocess.Popen(
base_command + ["up", "-d", "--remove-orphans"],
env=_docker_subprocess_env(),
)
try:
subprocess.run(
base_command + ["up", "-d", "--remove-orphans"],
env=_docker_subprocess_env(),
timeout=_QUICKSTART_UP_TIMEOUT.total_seconds(),
)
up_process.wait(timeout=_QUICKSTART_UP_TIMEOUT.total_seconds())
except subprocess.TimeoutExpired:
logger.debug("docker compose up timed out, will retry")
logger.debug("docker compose up timed out, sending SIGTERM")
up_process.terminate()
try:
up_process.wait(timeout=3)
except subprocess.TimeoutExpired:
logger.debug("docker compose up still running, sending SIGKILL")
up_process.kill()
up_process.wait()

# Check docker health every few seconds.
status = check_docker_quickstart()
Expand Down

0 comments on commit 419b8a7

Please sign in to comment.