You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by ra...@apache.org on 2026/08/14 03:29:06 UTC
(ranger) branch RANGER-5744 created (now 92c1c523b)
This is an automated email from the ASF dual-hosted git repository.
ramackri pushed a change to branch RANGER-5744
in repository https://gitbox.apache.org/repos/asf/ranger.git
at 92c1c523b RANGER-5744: Harden plugins-docker-build against Ozone KDC startup race
This branch includes the following new commits:
new 92c1c523b RANGER-5744: Harden plugins-docker-build against Ozone KDC startup race
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(ranger) 01/01: RANGER-5744: Harden plugins-docker-build against Ozone KDC startup race
Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ramackri pushed a commit to branch RANGER-5744
in repository https://gitbox.apache.org/repos/asf/ranger.git
commit 92c1c523b4240e141420a2f50a9f9ecc248c40f1
Author: ramk <ra...@cloudera.com>
AuthorDate: Fri Aug 14 08:58:50 2026 +0530
RANGER-5744: Harden plugins-docker-build against Ozone KDC startup race
Reduce flaky CI failures where ozone-datanode exits on Kerberos login
before the Ranger KDC is fully ready in Docker Compose smoke tests.
Co-authored-by: Cursor <cu...@cursor.com>
---
.github/workflows/ci.yml | 16 +++++
dev-support/ranger-docker/Dockerfile.ranger-kdc | 4 +-
.../ranger-docker/docker-compose.ranger-ozone.yml | 14 +++--
dev-support/ranger-docker/scripts/kdc/krb5.conf | 2 +
.../scripts/ozone/ozone-service-start.sh | 73 ++++++++++++++++++++++
5 files changed, 102 insertions(+), 7 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index b8273b2fe..9ecfa249a 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -247,6 +247,22 @@ jobs:
-f docker-compose.ranger-knox.yml \
-f docker-compose.ranger-ozone.yml up -d
+ - name: Wait for KDC Kerberos readiness
+ run: |
+ cd dev-support/ranger-docker
+ for i in $(seq 1 90); do
+ status=$(docker inspect -f '{{.State.Health.Status}}' ranger-kdc 2>/dev/null || echo missing)
+ if [ "$status" = "healthy" ]; then
+ echo "ranger-kdc is healthy after ${i} attempt(s)"
+ exit 0
+ fi
+ echo "Waiting for ranger-kdc (status=${status})..."
+ sleep 2
+ done
+ echo "ranger-kdc did not become healthy in time"
+ docker logs ranger-kdc || true
+ exit 1
+
- name: Check status of containers and remove them
run: |
sleep 60
diff --git a/dev-support/ranger-docker/Dockerfile.ranger-kdc b/dev-support/ranger-docker/Dockerfile.ranger-kdc
index a81119bff..4478ad37e 100644
--- a/dev-support/ranger-docker/Dockerfile.ranger-kdc
+++ b/dev-support/ranger-docker/Dockerfile.ranger-kdc
@@ -42,7 +42,7 @@ VOLUME /etc/keytabs
EXPOSE 88/tcp 88/udp 749/tcp
-HEALTHCHECK --interval=5s --timeout=3s --start-period=120s --retries=30 \
- CMD test -f /etc/keytabs/.provisioned && echo | nc -w 1 localhost 88 || exit 1
+HEALTHCHECK --interval=5s --timeout=5s --start-period=120s --retries=30 \
+ CMD test -f /etc/keytabs/.provisioned && kinit -kt /etc/keytabs/datanode/dn.keytab dn/datanode.rangernw@EXAMPLE.COM && kdestroy
ENTRYPOINT ["/entrypoint.sh"]
diff --git a/dev-support/ranger-docker/docker-compose.ranger-ozone.yml b/dev-support/ranger-docker/docker-compose.ranger-ozone.yml
index 26dad4fea..0de46d624 100644
--- a/dev-support/ranger-docker/docker-compose.ranger-ozone.yml
+++ b/dev-support/ranger-docker/docker-compose.ranger-ozone.yml
@@ -7,14 +7,16 @@ services:
- ./downloads/ozone-${OZONE_VERSION}:/opt/hadoop
- ./dist/keytabs/datanode:/etc/keytabs
- ./scripts/kdc/krb5.conf:/etc/krb5.conf:ro
+ - ./scripts/ozone/ozone-service-start.sh:/opt/ozone-service-start.sh:ro
networks:
- ranger
ports:
- 9864
depends_on:
ranger-kdc:
- condition: service_started
- command: bash -c "unset KERBEROS_ENABLED; sudo mkdir -p /data/hdds /data/metadata && sudo chown -R hadoop:hadoop /data && exec /opt/hadoop/bin/ozone datanode"
+ condition: service_healthy
+ restart: on-failure:3
+ command: bash -c "unset KERBEROS_ENABLED; export OZONE_KEYTAB_NAME=dn.keytab; bash /opt/ozone-service-start.sh bash -c 'sudo mkdir -p /data/hdds /data/metadata && sudo chown -R hadoop:hadoop /data && exec /opt/hadoop/bin/ozone datanode'"
env_file:
- ./scripts/ozone/docker-config
environment:
@@ -43,7 +45,7 @@ services:
- 9862:9862
depends_on:
ranger-kdc:
- condition: service_started
+ condition: service_healthy
scm:
condition: service_started
datanode:
@@ -68,6 +70,7 @@ services:
- ./downloads/ozone-${OZONE_VERSION}:/opt/hadoop
- ./dist/keytabs/scm:/etc/keytabs
- ./scripts/kdc/krb5.conf:/etc/krb5.conf:ro
+ - ./scripts/ozone/ozone-service-start.sh:/opt/ozone-service-start.sh:ro
networks:
- ranger
ports:
@@ -75,13 +78,14 @@ services:
- 9860:9860
depends_on:
ranger-kdc:
- condition: service_started
+ condition: service_healthy
env_file:
- ./scripts/ozone/docker-config
environment:
RANGER_KERBEROS_ENABLED: ${KERBEROS_ENABLED}
OZONE-SITE.XML_hdds.scm.safemode.min.datanode: "${OZONE_SAFEMODE_MIN_DATANODES:-1}"
- command: bash -c "unset KERBEROS_ENABLED; (test -f /data/metadata/scm/current/VERSION || /opt/hadoop/bin/ozone scm --init) && exec /opt/hadoop/bin/ozone scm"
+ restart: on-failure:3
+ command: bash -c "unset KERBEROS_ENABLED; export OZONE_KEYTAB_NAME=scm.keytab; bash /opt/ozone-service-start.sh bash -c '(test -f /data/metadata/scm/current/VERSION || /opt/hadoop/bin/ozone scm --init) && exec /opt/hadoop/bin/ozone scm'"
networks:
ranger:
diff --git a/dev-support/ranger-docker/scripts/kdc/krb5.conf b/dev-support/ranger-docker/scripts/kdc/krb5.conf
index 06565831f..deebd2fca 100644
--- a/dev-support/ranger-docker/scripts/kdc/krb5.conf
+++ b/dev-support/ranger-docker/scripts/kdc/krb5.conf
@@ -5,6 +5,8 @@
dns_lookup_realm = false
ticket_lifetime = 24h
forwardable = true
+ # Docker CI: avoid UDP KDC probes (PortUnreachableException) when KDC TCP is up first.
+ udp_preference_limit = 0
[realms]
EXAMPLE.COM = {
diff --git a/dev-support/ranger-docker/scripts/ozone/ozone-service-start.sh b/dev-support/ranger-docker/scripts/ozone/ozone-service-start.sh
new file mode 100755
index 000000000..18928fc60
--- /dev/null
+++ b/dev-support/ranger-docker/scripts/ozone/ozone-service-start.sh
@@ -0,0 +1,73 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Waits for Kerberos keytab + KDC before exec'ing Ozone SCM/datanode. CI smoke tests
+# hit PortUnreachableException when the datanode starts before KDC UDP/TCP is ready.
+
+set -euo pipefail
+
+KEYTAB_NAME="${OZONE_KEYTAB_NAME:-}"
+KDC_HOST="${KDC_HOST:-ranger-kdc.rangernw}"
+KDC_PORT="${KDC_PORT:-88}"
+MAX_WAIT_SEC="${OZONE_KERBEROS_WAIT_SEC:-120}"
+
+wait_for_keytab() {
+ if [[ -z "${KEYTAB_NAME}" ]] || [[ "${RANGER_KERBEROS_ENABLED:-}" != "true" ]]; then
+ return 0
+ fi
+
+ local keytab_path="/etc/keytabs/${KEYTAB_NAME}"
+ local deadline=$((SECONDS + MAX_WAIT_SEC))
+
+ echo "Waiting for keytab ${keytab_path} (up to ${MAX_WAIT_SEC}s)..."
+ while (( SECONDS < deadline )); do
+ if [[ -f "${keytab_path}" ]]; then
+ echo "Found keytab ${keytab_path}"
+ return 0
+ fi
+ sleep 2
+ done
+
+ echo "ERROR: timed out waiting for keytab ${keytab_path}" >&2
+ exit 1
+}
+
+wait_for_kdc() {
+ if [[ "${RANGER_KERBEROS_ENABLED:-}" != "true" ]]; then
+ return 0
+ fi
+
+ local deadline=$((SECONDS + MAX_WAIT_SEC))
+
+ echo "Waiting for KDC at ${KDC_HOST}:${KDC_PORT} (up to ${MAX_WAIT_SEC}s)..."
+ while (( SECONDS < deadline )); do
+ if (echo > "/dev/tcp/${KDC_HOST}/${KDC_PORT}") 2>/dev/null; then
+ # KDC healthcheck can pass slightly before clients succeed; brief settle.
+ sleep 3
+ echo "KDC reachable at ${KDC_HOST}:${KDC_PORT}"
+ return 0
+ fi
+ sleep 2
+ done
+
+ echo "ERROR: timed out waiting for KDC at ${KDC_HOST}:${KDC_PORT}" >&2
+ exit 1
+}
+
+wait_for_keytab
+wait_for_kdc
+exec "$@"