key9527 opened a new pull request, #18607:
URL: https://github.com/apache/dolphinscheduler/pull/18607

   <!--Thanks very much for contributing to Apache DolphinScheduler, we are 
happy that you want to help us improve DolphinScheduler! -->
   
   ## Was this PR generated or assisted by AI?
   NO
   <!--(Please answer YES or NO. If YES, please specify which parts were 
generated or assisted by AI)-->
   
   ## Purpose of the pull request
   
   <!--(For example: This pull request adds checkstyle plugin).-->
   
   ## Brief change log
   - add ingressClassName conf,support custom ingressClassName
   - fix alert-server register hostip
   <!--*(for example:)*
   - *Add maven-checkstyle-plugin to root pom.xml*
   -->
   
   ## Verify this pull request
   1.测试脚本,在容器环境里获取 getCanonicalHostName()
   ```sh
   root@dolphinscheduler-alert-57ff675dc5-9nbpj:/opt/dolphinscheduler# cat > 
DnsProbe.java << EOF
   > import java.net.InetAddress;
   > 
   > public class DnsProbe {
   >     public static void main(String[] args) throws Exception {
   >         InetAddress local = InetAddress.getLocalHost();
   >         System.out.println("getHostName      = " + local.getHostName());
   >         System.out.println("getCanonicalName = " + 
local.getCanonicalHostName()); 
   >         System.out.println("getHostAddress   = " + local.getHostAddress());
   >     }
   > }
   > EOF
   root@dolphinscheduler-alert-57ff675dc5-9nbpj:/opt/dolphinscheduler# 
   ```
   2.执行脚本,打印getHostAddress、getCanonicalName
   ```sh
   root@dolphinscheduler-alert-57ff675dc5-9nbpj:/opt/dolphinscheduler# javac 
DnsProbe.java 
   root@dolphinscheduler-alert-57ff675dc5-9nbpj:/opt/dolphinscheduler# java 
DnsProbe
   
   getHostName      = dolphinscheduler-alert-57ff675dc5-9nbpj
   getCanonicalName = dolphinscheduler-alert-57ff675dc5-9nbpj
   getHostAddress   = 10.244.1.200
   ```
   3.bugfix
   ```java
       public static String getHost(InetAddress inetAddress) {
           if (inetAddress != null) {
               if (KubernetesUtils.isKubernetesMode()) {
                    // 
alert-server是以deploy方式部署的,canonicalHost取到的是dolphinscheduler-alert-57ff675dc5-9nbpj,k8s里无法解析这种host
                   String canonicalHost = inetAddress.getCanonicalHostName();
                   String[] items = canonicalHost.split("\\.");
                   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();
           }
           return null;
       }
   ```
   <!--*(Please pick either of the following options)*-->
   
   This pull request is code cleanup without any test coverage.
   
   *(or)*
   
   This pull request is already covered by existing tests, such as *(please 
describe tests)*.
   
   (or)
   
   This change added tests and can be verified as follows:
   
   <!--*(example:)*
   - *Added dolphinscheduler-dao tests for end-to-end.*
   - *Added CronUtilsTest to verify the change.*
   - *Manually verified the change by testing locally.* -->
   
   (or)
   
   ## Pull Request Notice
   [Pull Request 
Notice](https://github.com/apache/dolphinscheduler/blob/dev/docs/docs/en/contribute/join/pull-request.md)
   
   If your pull request contains incompatible change, you should also add it to 
`docs/docs/en/guide/upgrade/incompatible.md`
   


-- 
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