Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Consul deregister 'failing' services

I have consul running on Consul v0.5.2 version & services running in Mesos. Services keep moving from 1 server to another.

Is there way to deregister services in consul that are in 'failing' state? I am able to get the list of services in failing state using this curl

curl http://localhost:8500/v1/health/state/critical

Issue that we are seeing is over a period of time in consul UI we have stale data & making the whole UI unusable

like image 583
DevOpsNewB Avatar asked Oct 13 '16 00:10

DevOpsNewB


People also ask

How do I deregister a Consul service?

If the service was registered with a configuration file, then deleting that file and reloading Consul is the correct method to deregister. See Service Definition for more information about registering services generally.

How do I cancel a Consul server?

Stop the agent Stop the Consul agent by using the consul leave command. This will gracefully stop the agent, causing it to leave the Consul datacenter and shut down.

How do I know if a Consul agent is running?

Health Checks The easiest way to view initial health status is by visiting the Consul Web UI at http://localhost:8500/ui . Click through to a specific service such as the counting service. The status of the service on each node will be displayed.

How do I remove a Consul?

Consul K8s CLI Issue the consul-k8s uninstall command to remove Consul on Kubernetes. You can specify the installation name, namespace, and data retention behavior using the applicable options. By default, the uninstall preserves the secrets and PVCs that are provisioned by Consul on Kubernetes.


1 Answers

Consul by default do not deregister unhealthy services instead marks them as critical. From Consul 0.7 there is special option (deregister_critical_service_after) that allows you to define time after unhealthy service will be deregstered

From Consul 0.7 Changelog

Automatic Service Deregistration: Added a new deregister_critical_service_after timeout field for health checks which will cause the service associated with that check to get deregistered if the check is critical for longer than the timeout. This is useful for cleanup of health checks registered natively by applications, or in other situations where services may not always be cleanly shutdown. GH-679

If you are usign Marathon then you can consider using allegro/marathon-consul it will deregister task when its dead

like image 99
janisz Avatar answered Sep 24 '22 23:09

janisz