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

consul node can't be deregister #22071

Open
whc9527 opened this issue Jan 14, 2025 · 0 comments
Open

consul node can't be deregister #22071

whc9527 opened this issue Jan 14, 2025 · 0 comments

Comments

@whc9527
Copy link

whc9527 commented Jan 14, 2025

Consul version: Consul v1.9.0
Consul Cluster Node Total: 2w+
Consul Server Total: 5

8.219.x.x This node is unhealthy on Consul console, and this machine has not been deleted by Consul for several days, then I plan to call consul api to delete it. But the curl command keeps sticking (calling other consul server nodes for deregister operations doesn't stick)

Image

deregister command
curl --header X-Consul-Token:2a825e81-b249-433d-a22e-xxxxx --request PUT http://172.31.x.x:8500/v1/agent/service/deregister/tpn,tpn_adx_micro,fk_tpn_adx_micro,8.209.x.x,heartbeat

The node 8.219.x.x is currently registered on the node 172.31.x.x , i login the node 172.31.x.x and use grep command to view some data of 8.219.x.x, and find that 8.219.x.x displays "passing" in consul data, Is this a Bug?

Image

use this code to register to consul cluster

func register(agentConfig config.Config) error {
	consulId := fmt.Sprintf("%s,%s,%s,%s,heartbeat", agentConfig.Tagteam, agentConfig.Taggroup, agentConfig.Tagname, agentConfig.PublicIP)
	registration := new(consulapi.AgentServiceRegistration)
	registration.Name = "hawkeye"
	registration.ID = consulId
	registration.Port = agentConfig.Port
	registration.Address = agentConfig.PublicIP
	registration.Tags = []string{consulId}
	registration.Meta = map[string]string{
		"public_ip": agentConfig.PublicIP,
		"tagteam":   agentConfig.Tagteam,
		"taggroup":  agentConfig.Taggroup,
		"tagname":   agentConfig.Tagname,
	}
	registration.Check = &consulapi.AgentServiceCheck{
		HTTP:                           fmt.Sprintf("http://%s:%d/heartbeat/%s_%s_%s", registration.Address, agentConfig.Port, agentConfig.Tagteam, agentConfig.Taggroup, agentConfig.Tagname),
		Timeout:                        "10s",
		Interval:                       "20s",
		DeregisterCriticalServiceAfter: "10s",
		Status:                         "passing",
	}
	return consul_client.Agent().ServiceRegister(registration)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant