From 05254bdf35ee7e7826037b491cda71aa290ec4d1 Mon Sep 17 00:00:00 2001 From: Zhang Lei Date: Wed, 4 Dec 2024 17:20:33 +0800 Subject: [PATCH] refactor(interactive): Use netcat to check service readiness (#4342) Previously we used a Gremlin query to check whether the Gremlin service is ready, which may reveal unexpected problems. It is better to use netcat to find out whether the endpoint is ready for serving. --- charts/graphscope-store/templates/configmap.yaml | 7 ++++++- k8s/dockerfiles/coordinator.Dockerfile | 2 +- k8s/dockerfiles/graphscope-dev-wheel.Dockerfile | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/charts/graphscope-store/templates/configmap.yaml b/charts/graphscope-store/templates/configmap.yaml index b504850f8f7f..c690d3f33809 100644 --- a/charts/graphscope-store/templates/configmap.yaml +++ b/charts/graphscope-store/templates/configmap.yaml @@ -181,7 +181,12 @@ data: export GRPC_PORT=${GROOT_GRPC_PORT} export GREMLIN_PORT=${GROOT_GREMLIN_PORT} echo "${HOST} ${GRPC_PORT} ${GREMLIN_PORT}" - python3 -c 'import base64;import os;from gremlin_python.driver.client import Client;ip=os.getenv("HOST");gremlin_port=os.getenv("GREMLIN_PORT");graph_url=f"ws://{ip}:{gremlin_port}/gremlin";username=os.getenv("GROOT_USERNAME");password=base64.b64decode(os.getenv("GROOT_PASSWORD")).decode("utf-8");client = Client(graph_url, "g", username=username, password=password); ret = client.submit("g.V().limit(1)").all().result(); client.close();' && break + cmd="nc -zv ${HOST} ${GREMLIN_PORT}" + res=$(eval $cmd 2>&1) + if [[ $res == *succeeded* ]]; then + # Expected Output is + break + fi sleep 3 done diff --git a/k8s/dockerfiles/coordinator.Dockerfile b/k8s/dockerfiles/coordinator.Dockerfile index d55086472146..d12cbe99c043 100644 --- a/k8s/dockerfiles/coordinator.Dockerfile +++ b/k8s/dockerfiles/coordinator.Dockerfile @@ -36,7 +36,7 @@ FROM ubuntu:22.04 AS coordinator ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update -y && \ - apt-get install -y sudo python3-pip openmpi-bin curl tzdata && \ + apt-get install -y sudo python3-pip openmpi-bin curl tzdata netcat && \ apt-get clean -y && \ rm -rf /var/lib/apt/lists/* diff --git a/k8s/dockerfiles/graphscope-dev-wheel.Dockerfile b/k8s/dockerfiles/graphscope-dev-wheel.Dockerfile index 4383c3a1bc0b..69e6dded5a1d 100644 --- a/k8s/dockerfiles/graphscope-dev-wheel.Dockerfile +++ b/k8s/dockerfiles/graphscope-dev-wheel.Dockerfile @@ -51,6 +51,7 @@ RUN yum install -y sudo vim && \ yum remove java-1.8.0-openjdk-devel java-1.8.0-openjdk java-1.8.0-openjdk-headless -y && \ yum install java-11-openjdk-devel -y && \ yum clean all -y --enablerepo='*' && \ + yum install -y netcat && \ rm -rf /var/cache/yum RUN mkdir -p /opt/graphscope /opt/vineyard && chown -R graphscope:graphscope /opt/graphscope /opt/vineyard