Open liuchenrang opened 1 month ago
I analyze the code in service_client.go, in this code. Func (c * ServiceClient) sync. 4 detections will be skipped, resulting in deletion. The first place. Check whether the service is recorded locally, and the program remarks are as follows. / / Known service, skip. The second place. Code is if! isNomadService (id) | |! c.isClientAgent. Since cleint=true is turned on, this is also logical. Finally, the cancellation service deletion logic is reached. Question! If you understand that nomad provides check services, your app does not need to interface with consul service registration and discovery. If you do so, you should have no problem. Here I want to use the official check function, so there is a problem with feedback.
If it's bug, I think the reason is. This code c.services. This is a local service list, but the last traversal used all the service lists registered in consul, resulting in the deletion of services managed by other nodes, and mutual deletion due to cluster mode!
Hi @liuchenrang! Does each one of your Nomad client agents have its own Consul agent? They should not share Consul agents, as described in the Consul configuration docs:
An important requirement is that each Nomad agent talks to a unique Consul agent. Nomad agents should be configured to talk to Consul agents and not Consul servers. If you are observing flapping services, you may have multiple Nomad agents talking to the same Consul agent. As such avoid configuring Nomad to talk to Consul via DNS such as consul.service.consul
Nomad version
Output from
nomad version
v1.7.7Operating system and Environment details
Issue
In cluster mode, both client and server are enabled, and the deployment type is service. The service will be unregistered and automatically registered later
Reproduction steps
1 cluster mode 3 sets. 2 on a single node, client and server are enabled at the same time. 3 deploy 3 sets of whoami 4 consul cluster
Expected Result
Three whoami are stable online.
Actual Result
Periodically drop the line, and soon come online again.
Job file (if appropriate)
Nomad Server logs (if appropriate)
Nomad Client logs (if appropriate)
(edited by @tgross to make syntax legible)