Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

未使用address-server lookup时health接口返回响应'DOWN:address server down' #11499

Closed
zhanggang807 opened this issue Dec 12, 2023 · 1 comment · Fixed by #11508
Closed
Assignees
Labels
kind/bug Category issues or prs related to bug.

Comments

@zhanggang807
Copy link

zhanggang807 commented Dec 12, 2023

Describe the bug
未配置使用address-server lookup时health接口返回响应'DOWN:address server down'

Expected behavior
未配置使用address-server lookup时health接口返回响应'UP'

Actually behavior
未配置使用address-server lookup时health接口返回响应'DOWN:address server down'

How to Reproduce
Steps to reproduce the behavior:

  1. 集群部署,使用cluster.conf配置集群节点
  2. application.properties文件中未启用nacos.core.member.lookup.type配置
  3. 访问接口curl http://localhost:8848/nacos/v1/cs/health

Desktop (please complete the following information):

  • OS: centos
  • Version nacos-server 2.0.2, nacos-client 2.0.2
  • Module [e.g. naming/config]
  • SDK [e.g. original, spring-cloud-alibaba-nacos, dubbo]

Additional context
com.alibaba.nacos.config.server.controller.HealthController#getHealth 关于isAddressServerHealth的判断逻辑需要优化一下

private boolean isAddressServerHealthy() {
        Map<String, Object> info = memberManager.getLookup().info();
        return info != null && info.get("addressServerHealth") != null && Boolean
                .parseBoolean(info.get("addressServerHealth").toString());
    }

非AddressServerMemberLookup时 addressServerHealth不是true,所以影响了health接口的响应内容

    @GetMapping
    public String getHealth() {
        // TODO UP DOWN WARN
        StringBuilder sb = new StringBuilder();
        String dbStatus = dataSourceService.getHealth();
        boolean addressServerHealthy = isAddressServerHealthy();
        if (dbStatus.contains(HEALTH_UP) && addressServerHealthy && ServerMemberManager.isInIpList()) {
            sb.append(HEALTH_UP);
        } else if (dbStatus.contains(HEALTH_WARN) && addressServerHealthy && ServerMemberManager.isInIpList()) {
            sb.append("WARN:");
            sb.append("slave db (").append(dbStatus.split(":")[1]).append(") down. ");
        } else {
            sb.append("DOWN:");
            if (dbStatus.contains(HEALTH_DOWN)) {
                sb.append("master db (").append(dbStatus.split(":")[1]).append(") down. ");
            }
        
            if (!addressServerHealthy) {
                sb.append("address server down. ");
            }
            if (!ServerMemberManager.isInIpList()) {
                sb.append("server ip ").append(InetUtils.getSelfIP())
                        .append(" is not in the serverList of address server. ");
            }
        }
    
        return sb.toString();
    }
@onewe onewe added kind/research kind/bug Category issues or prs related to bug. and removed kind/research labels Dec 13, 2023
@onewe onewe self-assigned this Dec 13, 2023
@onewe
Copy link
Collaborator

onewe commented Dec 13, 2023

@i will resolve it@

onewe added a commit to onewe/nacos that referenced this issue Dec 13, 2023
onewe added a commit to onewe/nacos that referenced this issue Dec 15, 2023
onewe added a commit to onewe/nacos that referenced this issue Dec 15, 2023
KomachiSion pushed a commit that referenced this issue Dec 19, 2023
* [ISSUES #11499] fix address server health check error

Close #11499

* [ISSUES #11499] add some unit tests for HealthController
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Category issues or prs related to bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants