Skip to content
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

fix(cli): make quickstart docker compose up command more robust #8929

Merged
merged 2 commits into from
Oct 4, 2023
Merged
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
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
Loading