Open remilapeyre opened 4 years ago
The core problem here is that a Consul agent assumes it is the source-of-truth for all services registered with its node. When it sees the terraform registered service that it knows nothing about, it treats that just like a service that was registered locally but then deregistered and removes it.
"External" nodes can be registered and services for them managed in this manner.
The question this brings up is whether or not it might be a good idea for Consul to support some way to register a service via the Catalog API and mark it as "managed externally" but still have the Agent run the health checks.
There are many UX related things to consider here like what happens if someone then tries to go direct to the Agent apis and register or update that same service? I am sure there are others too.
The documentation at https://www.consul.io/api/catalog.html#register-entity could be improved. It currently reads:
It is usually preferable to instead use the agent endpoints for registration as they are simpler and perform anti-entropy.
But it's never appropriate to register internal services that way.
When a node exists, would it be possible to forward the registration call to the agent so it can register the new service?
Services registered using
/v1/catalog/register
get removed during the anty-entropy sync. As far as I can tell it does not happen when using the agent endpoint.I noticed this will looking into https://github.com/terraform-providers/terraform-provider-consul/issues/187
Reproduction Steps
Consul log