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

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


The following commit(s) were added to refs/heads/master by this push:
     new 41d95dd3286 HDDS-17137. Bracket IPv6 literals in the SCM web UI 
datanode link and Docker entrypoint WAITFOR (#11641)
41d95dd3286 is described below

commit 41d95dd32860dfd90988edb797f4aa8e78d9bba8
Author: Mark Tsai <[email protected]>
AuthorDate: Wed Oct 21 20:39:41 2026 +0800

    HDDS-17137. Bracket IPv6 literals in the SCM web UI datanode link and 
Docker entrypoint WAITFOR (#11641)
---
 .../main/resources/webapps/scm/scm-overview.html   |  2 +-
 .../src/main/resources/webapps/scm/scm.js          |  1 +
 .../dist/src/main/dockerlibexec/entrypoint.sh      | 10 ++-
 .../dist/src/test/shell/entrypoint_waitfor.bats    | 72 ++++++++++++++++++++++
 4 files changed, 82 insertions(+), 3 deletions(-)

diff --git 
a/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm-overview.html 
b/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm-overview.html
index dc73ebc4706..6715ed83c0d 100644
--- a/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm-overview.html
+++ b/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm-overview.html
@@ -258,7 +258,7 @@ <h2>Node Status</h2>
         <tr ng-repeat="typestat in nodeStatus|orderBy:columnName:reverse">
             <td ng-switch="typestat.port > 0">
                 <span ng-switch-when="true">
-                    <a 
href="{{typestat.protocol}}://{{typestat.hostname}}:{{typestat.port}}" 
target="_blank">{{typestat.hostname}}</a>
+                    <a 
href="{{typestat.protocol}}://{{typestat.urlhost}}:{{typestat.port}}" 
target="_blank">{{typestat.hostname}}</a>
                 </span>
                 <span ng-switch-when="false">
                     {{typestat.hostname}}
diff --git a/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm.js 
b/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm.js
index 73ecda3d49c..397f73e2136 100644
--- a/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm.js
+++ b/hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm.js
@@ -150,6 +150,7 @@
                                 }
                                 return {
                                     hostname: key,
+                                    urlhost: key.includes(":") ? "[" + key + 
"]" : key,
                                     opstate: value && value.find((element) => 
element.key === "OPSTATE").value,
                                     usedspacepercent: value && 
value.find((element) => element.key === "USEDSPACEPERCENT").value,
                                     capacity: value && value.find((element) => 
element.key === "CAPACITY").value,
diff --git a/hadoop-ozone/dist/src/main/dockerlibexec/entrypoint.sh 
b/hadoop-ozone/dist/src/main/dockerlibexec/entrypoint.sh
index 2c5cf9f3358..04d2a0abba3 100755
--- a/hadoop-ozone/dist/src/main/dockerlibexec/entrypoint.sh
+++ b/hadoop-ozone/dist/src/main/dockerlibexec/entrypoint.sh
@@ -32,13 +32,19 @@ fi
 #
 # export WAITFOR=localhost:9878
 #
+# An IPv6 literal must be enclosed in square brackets:
+#
+# export WAITFOR=[2001:db8::1]:9878
+#
 # With an optional parameter, you can also set the maximum
 # time of waiting with (in seconds) with WAITFOR_TIMEOUT.
 # (The default is 300 seconds / 5 minutes.)
 if [ -n "$WAITFOR" ]; then
   echo "Waiting for the service $WAITFOR"
-  WAITFOR_HOST=$(printf "%s\n" "$WAITFOR"| cut -d : -f 1)
-  WAITFOR_PORT=$(printf "%s\n" "$WAITFOR"| cut -d : -f 2)
+  WAITFOR_HOST=${WAITFOR%:*}
+  WAITFOR_HOST=${WAITFOR_HOST#\[}
+  WAITFOR_HOST=${WAITFOR_HOST%\]}
+  WAITFOR_PORT=${WAITFOR##*:}
   for i in $(seq "${WAITFOR_TIMEOUT:-300}" -1 0) ; do
     set +e
     nc -z "$WAITFOR_HOST" "$WAITFOR_PORT" > /dev/null 2>&1
diff --git a/hadoop-ozone/dist/src/test/shell/entrypoint_waitfor.bats 
b/hadoop-ozone/dist/src/test/shell/entrypoint_waitfor.bats
new file mode 100644
index 00000000000..a8c9efd13fa
--- /dev/null
+++ b/hadoop-ozone/dist/src/test/shell/entrypoint_waitfor.bats
@@ -0,0 +1,72 @@
+#!/usr/bin/env 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.
+
+#
+# Can be executed with bats (https://github.com/bats-core/bats-core)
+# bats entrypoint_waitfor.bats
+#
+
+ENTRYPOINT="${BATS_TEST_DIRNAME}/../../main/dockerlibexec/entrypoint.sh"
+
+setup() {
+  RELTMP="${BATS_TEST_DIRNAME}/../../../target/test-dir/bats.$$.${RANDOM}"
+  mkdir -p "${RELTMP}"
+
+  TMP=$(cd -P -- "${RELTMP}" >/dev/null && pwd -P)
+  export TMP
+
+  # Stub nc on PATH: record its arguments and fail, so that entrypoint.sh
+  # makes a single attempt (WAITFOR_TIMEOUT=0) and exits before exec.
+  cat > "${TMP}/nc" <<'EOF'
+#!/usr/bin/env bash
+echo "$*" > "${NC_ARGS_FILE}"
+exit 1
+EOF
+  chmod +x "${TMP}/nc"
+
+  export NC_ARGS_FILE="${TMP}/nc.args"
+  export PATH="${TMP}:${PATH}"
+  export WAITFOR_TIMEOUT=0
+}
+
+teardown() {
+  rm -rf "${TMP}"
+}
+
+assert_nc_args() {
+  export WAITFOR="$1"
+
+  run "${ENTRYPOINT}" true
+
+  [[ "$status" -eq 1 ]]
+  [[ "$(cat "${NC_ARGS_FILE}")" == "$2" ]]
+}
+
+@test "WAITFOR with hostname" {
+  assert_nc_args "localhost:9878" "-z localhost 9878"
+}
+
+@test "WAITFOR with IPv4 address" {
+  assert_nc_args "10.0.0.1:9878" "-z 10.0.0.1 9878"
+}
+
+@test "WAITFOR with bracketed IPv6 address" {
+  assert_nc_args "[2001:db8::1]:9878" "-z 2001:db8::1 9878"
+}
+
+@test "WAITFOR with bracketed IPv6 loopback" {
+  assert_nc_args "[::1]:9876" "-z ::1 9876"
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to