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

SbloodyS pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 9c0f9ae266 [Fix-17883] Fix K8s Alert HTTP test sending failed by using 
IP for non-StatefulSet pods (#17883) (#18574)
9c0f9ae266 is described below

commit 9c0f9ae266eb15f757a17ac51a39fbc25e72e012
Author: Arvin <[email protected]>
AuthorDate: Mon Aug 31 11:34:19 2026 +0800

    [Fix-17883] Fix K8s Alert HTTP test sending failed by using IP for 
non-StatefulSet pods (#17883) (#18574)
---
 .../java/org/apache/dolphinscheduler/common/utils/NetUtils.java   | 5 ++++-
 .../org/apache/dolphinscheduler/common/utils/NetUtilsTest.java    | 8 ++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git 
a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/NetUtils.java
 
b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/NetUtils.java
index 12d96e2ad9..6aef3492dd 100644
--- 
a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/NetUtils.java
+++ 
b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/NetUtils.java
@@ -94,7 +94,10 @@ public class NetUtils {
                 if (items.length == 6 && "svc".equals(items[3])) {
                     return String.format("%s.%s", items[0], items[1]);
                 }
-                return canonicalHost;
+                if (inetAddress instanceof Inet6Address) {
+                    return normalizeV6Address((Inet6Address) 
inetAddress).getHostAddress();
+                }
+                return inetAddress.getHostAddress();
             }
             if (inetAddress instanceof Inet6Address) {
                 return normalizeV6Address((Inet6Address) 
inetAddress).getHostAddress();
diff --git 
a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/NetUtilsTest.java
 
b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/NetUtilsTest.java
index 880ad4dc90..b0aee0fcfb 100644
--- 
a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/NetUtilsTest.java
+++ 
b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/NetUtilsTest.java
@@ -64,12 +64,16 @@ public class NetUtilsTest {
             address = mock(InetAddress.class);
             
when(address.getCanonicalHostName()).thenReturn("dolphinscheduler.cluster-domain.example");
             when(address.getHostName()).thenReturn("dolphinscheduler");
-            Assertions.assertEquals("dolphinscheduler.cluster-domain.example", 
NetUtils.getHost(address));
+            when(address.getHostAddress()).thenReturn("10.0.0.1");
+            Assertions.assertEquals("10.0.0.1", NetUtils.getHost(address));
 
+            // Regression test for Kubernetes Deployment pod: short hostname 
without svc suffix
+            // should fall back to getHostAddress() to return the IP address
             address = mock(InetAddress.class);
             
when(address.getCanonicalHostName()).thenReturn("dolphinscheduler-worker-0");
             
when(address.getHostName()).thenReturn("dolphinscheduler-worker-0");
-            Assertions.assertEquals("dolphinscheduler-worker-0", 
NetUtils.getHost(address));
+            when(address.getHostAddress()).thenReturn("10.0.0.2");
+            Assertions.assertEquals("10.0.0.2", NetUtils.getHost(address));
         }
     }
 

Reply via email to