Log warnings if there are multiple application and/or admin connectors #189
Labels
enhancement
A request for change or improvement to an existing feature
Milestone
If a Dropwizard application contains more than one application or admin connector, then only the last connector's host and port are registered with Consul in
ConsulServiceListener.
This can cause problems depending on which scheme and port are registered with Consul.This "last wins" has been the library's behavior for many years now. However, we just encountered it in one specific service which had two application connectors: an "https" one for external clients and an "http" one that binds only to localhost and is used for specialized inter-process communication with another application running locally on the same server.
The localhost application connector was the last one in the YAML configuration, and its "http" scheme and application port was the one registered in Consul. Because the scheme was "http" and not "https", this also caused Consul to de-register the service, since it was trying to contact the application health check using "http" on the admin port instead of "https".
We fixed it by moving the localhost connector as the first one, so that the last one is the one available to external clients and is registered with Consul. And, the scheme was then "https" so Consul was able to communicate with the service health check.
We could have also fixed it by explicitly setting a specific port in the
ConsulFactory
configuration.For now, we do not plan to change the existing behavior, but we will add WARN-level logging if there are more than one application and/or admin connector, or if there is a connector with an unknown name (not "application" or "admin") which indicates the "simple" server type is in use. The logging should indicate that only the last scheme and port are registered with Consul unless there is explicit configuration for
ConsulFactory
.If the logging had existed when this happened, we could have tracked the problem down much more quickly.
Later, we might consider adding a configuration option that would fail-fast if there are multiple application and/or admin connectors but there is no explicit configuration for the service port, scheme, and/or host.
The text was updated successfully, but these errors were encountered: