This is an automated email from the ASF dual-hosted git repository.

ayushtkn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new dd8cc149164 HIVE-29709: Add health check to docker (#6591)
dd8cc149164 is described below

commit dd8cc1491645b3c608647148109c1bfe09fbc00e
Author: Ayush Saxena <[email protected]>
AuthorDate: Thu Jul 16 21:27:35 2026 +0530

    HIVE-29709: Add health check to docker (#6591)
---
 packaging/src/docker/conf/tez-site.xml.template |  4 ++
 packaging/src/docker/docker-compose.yml         | 49 +++++++++++++++++++++++--
 packaging/src/docker/entrypoint.sh              |  1 +
 packaging/src/docker/start-hive.sh              |  4 +-
 4 files changed, 53 insertions(+), 5 deletions(-)

diff --git a/packaging/src/docker/conf/tez-site.xml.template 
b/packaging/src/docker/conf/tez-site.xml.template
index a420137a97e..c05a6f2d004 100644
--- a/packaging/src/docker/conf/tez-site.xml.template
+++ b/packaging/src/docker/conf/tez-site.xml.template
@@ -33,6 +33,10 @@
         <name>tez.am.registry.namespace</name>
         <value>${TEZ_AM_REGISTRY_NAMESPACE}</value>
     </property>
+    <property>
+        <name>tez.am.rpc.port</name>
+        <value>${TEZ_AM_RPC_PORT}</value>
+    </property>
     <property>
         <name>tez.local.mode</name>
         <value>false</value>
diff --git a/packaging/src/docker/docker-compose.yml 
b/packaging/src/docker/docker-compose.yml
index 0374255db65..40a4bdefdf5 100644
--- a/packaging/src/docker/docker-compose.yml
+++ b/packaging/src/docker/docker-compose.yml
@@ -32,11 +32,17 @@ services:
       - hive-db:/var/lib/postgresql
     networks:
       - hive
+    healthcheck:
+      test: ["CMD-SHELL", "pg_isready -U hive -d metastore_db"]
+      interval: 5s
+      timeout: 3s
+      retries: 30
 
   metastore:
     image: apache/hive:${HIVE_VERSION}
     depends_on:
-      - postgres
+      postgres:
+        condition: service_healthy
     restart: unless-stopped
     container_name: metastore
     hostname: metastore
@@ -67,11 +73,18 @@ services:
         - ./jars:/tmp/ext-jars:ro
     networks:
       - hive
+    healthcheck:
+      test: ["CMD-SHELL", "bash -c 'echo > /dev/tcp/localhost/9083'"]
+      interval: 5s
+      timeout: 5s
+      retries: 30
+      start_period: 30s
 
   hiveserver2:
     image: apache/hive:${HIVE_VERSION}
     depends_on:
-      - metastore
+      metastore:
+        condition: service_healthy
     restart: unless-stopped
     container_name: hiveserver2
     hostname: hiveserver2
@@ -125,6 +138,12 @@ services:
       - ./jars:/tmp/ext-jars:ro
     networks:
       - hive
+    healthcheck:
+      test: ["CMD-SHELL", "bash -c 'echo > /dev/tcp/localhost/10000'"]
+      interval: 10s
+      timeout: 10s
+      retries: 30
+      start_period: 40s
 
   zookeeper:
     profiles:
@@ -137,10 +156,17 @@ services:
       - '2181:2181'
     networks:
       - hive
+    environment:
+      ZOO_4LW_COMMANDS_WHITELIST: ruok
     volumes:
       - zookeeper_data:/data
       - zookeeper_datalog:/datalog
       - zookeeper_logs:/logs
+    healthcheck:
+      test: ["CMD-SHELL", "echo ruok | nc -w 2 127.0.0.1 2181 | grep imok"]
+      interval: 5s
+      timeout: 3s
+      retries: 30
 
   tezam:
     profiles:
@@ -149,7 +175,8 @@ services:
     container_name: tezam
     hostname: tezam
     depends_on:
-      - zookeeper
+      zookeeper:
+        condition: service_healthy
     restart: on-failure:3
     environment:
       USER: hive
@@ -157,6 +184,7 @@ services:
 
       TEZ_FRAMEWORK_MODE: STANDALONE_ZOOKEEPER
       TEZ_AM_ZOOKEEPER_QUORUM: zookeeper:2181
+      TEZ_AM_RPC_PORT: '15100'
 
       # LLAP daemon discovery
       HIVE_ZOOKEEPER_QUORUM: zookeeper:2181
@@ -171,13 +199,20 @@ services:
       - scratch:/opt/hive/scratch
     networks:
       - hive
+    healthcheck:
+      test: ["CMD-SHELL", "bash -c 'echo > 
/dev/tcp/localhost/$${TEZ_AM_RPC_PORT}'"]
+      interval: 5s
+      timeout: 5s
+      retries: 30
+      start_period: 20s
 
   llapdaemon:
     profiles:
       - llap
     image: apache/hive:${HIVE_VERSION}
     depends_on:
-      - zookeeper
+      zookeeper:
+        condition: service_healthy
     restart: unless-stopped
     environment:
       USER: hive
@@ -205,6 +240,12 @@ services:
       - scratch:/opt/hive/scratch
     networks:
       - hive
+    healthcheck:
+      test: ["CMD-SHELL", "bash -c 'echo > /dev/tcp/localhost/15001'"]
+      interval: 5s
+      timeout: 5s
+      retries: 30
+      start_period: 20s
 
 volumes:
   hive-db:
diff --git a/packaging/src/docker/entrypoint.sh 
b/packaging/src/docker/entrypoint.sh
index 5ec094edce3..a043ef09502 100644
--- a/packaging/src/docker/entrypoint.sh
+++ b/packaging/src/docker/entrypoint.sh
@@ -48,6 +48,7 @@ export 
HIVE_SERVER2_TEZ_USE_EXTERNAL_SESSIONS="${HIVE_SERVER2_TEZ_USE_EXTERNAL_S
 export TEZ_FRAMEWORK_MODE="${TEZ_FRAMEWORK_MODE:-}"
 export TEZ_AM_REGISTRY_NAMESPACE="${TEZ_AM_REGISTRY_NAMESPACE:-/tez_am/server}"
 export 
TEZ_AM_ZOOKEEPER_QUORUM="${TEZ_AM_ZOOKEEPER_QUORUM:-${HIVE_ZOOKEEPER_QUORUM}}"
+export TEZ_AM_RPC_PORT="${TEZ_AM_RPC_PORT:-0}"
 
 envsubst < $HIVE_HOME/conf/core-site.xml.template > 
$HIVE_HOME/conf/core-site.xml
 envsubst < $HIVE_HOME/conf/hive-site.xml.template > 
$HIVE_HOME/conf/hive-site.xml
diff --git a/packaging/src/docker/start-hive.sh 
b/packaging/src/docker/start-hive.sh
index a76eea2cf31..94ae369ee4f 100755
--- a/packaging/src/docker/start-hive.sh
+++ b/packaging/src/docker/start-hive.sh
@@ -58,4 +58,6 @@ export COMPOSE_FILE="$COMPOSE_FILES"
 
 echo "Starting Hive cluster (mode=$HIVE_EXECUTION_MODE)"
 
-docker compose $PROFILE up -d $SCALE
+docker compose $PROFILE up -d --wait $SCALE
+
+echo "Hive cluster is ready."

Reply via email to