zhang-arvin opened a new pull request, #18574:
URL: https://github.com/apache/dolphinscheduler/pull/18574

   ## Purpose
   
   Fix the issue where Alert HTTP test sending fails in Kubernetes environment.
   
   **Issue**: #17883
   
   ## Root Cause
   
   When running in Kubernetes mode, `NetUtils.getHost()` returns the canonical 
hostname (pod name) for Deployment-based pods like Alert Server. For example, 
`dolphinscheduler-alert-67b7c695cb-v9b82`. This pod name is not DNS-resolvable 
by other pods, causing the API server to fail connecting to the Alert Server 
with `UnknownHostException`.
   
   The existing code handles StatefulSet pods correctly (pattern: 
`<pod>.<service>.<ns>.svc.cluster.local`), extracting `pod.service` which is 
resolvable. But for Deployment pods, the canonical hostname is just the pod 
name.
   
   ## Fix
   
   In `NetUtils.getHost(InetAddress)`, when in Kubernetes mode and the 
canonical hostname does NOT match the StatefulSet pattern (6 parts with "svc" 
at index 3), fall back to the pod's IP address using 
`inetAddress.getHostAddress()`. The IP address is always routable within the 
Kubernetes cluster.
   
   ## Changes
   
   - 
`dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/NetUtils.java`:
 Changed line 97 from `return canonicalHost;` to `return 
inetAddress.getHostAddress();`
   
   This is a one-line fix that preserves the existing behavior for StatefulSet 
pods (Master/Worker) while fixing the issue for Deployment pods (Alert Server).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to