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
Add configuration option service_prefix
for Consul DCS
#1543
base: master
Are you sure you want to change the base?
Add configuration option service_prefix
for Consul DCS
#1543
Conversation
service_prefix
for Consul DCSservice_prefix
for Consul DCS
Removal of unnecessary private member variable as suggested. Co-authored-by: Alexander Kukushkin <cyberdemn@gmail.com>
After looking at it for the second time I've got a question, why is it a prefix, and no a suffix? |
I decided to go with the prefix approach as it seemed more natural (I'm used to the Debian patroni package, where the systemd service is called e.g. ´patroni@9.6-batman.service´). But in the end, it's personal preference which shouldn't affect usage. With regards to 'fitting into DNS', I don't think that matters concerning functionality as any service name in consul isn't anything more than a plain string. But that comment led me to another question: Maybe, the service published by patroni should always be named plain and simple The differentiation between different clusters would then happen solely based on consul tags, one of which would be the scope name. I guess this would be the preferred approach, which would require some more changes. This approach also doesn't come without downsides. Namely, DNS Service Queries against consul support only one single tag, e.g. Of course, consul provides 'prepared query templates' stored in the cluster itself to work around that limitation, but that introduces another layer of complexity that I wouldn't want to be required to use for 'simple' use cases. As a compromise, the following changes could be implemented:
This way, a user can choose to still manually incorporate the scope name in the service name by just setting |
Ok, it seems that the |
I forgot about backwards compatibilty for a moment. Considering that, In addition, If these suggestions are acceptable, I would change this PR to implement the first part and do the tagging thing in a second PR. |
@awiller42, sounds like a plan. Please put everything into a single PR. |
To enhance service registration in consul, I'd like to suggest to add a configuration option
service_prefix
to the consul section of the patroni configuration.This option allows to prefix the registered service name with an arbitrary string. The need for this option arises as the
scope
name usually doesn't include a string likepatroni-
(as this would be redundant in thescope
name itself). As a result, the service name registered in consul is very generic and somewhat meaningless / lacking the type-of-service information.With the change introduced in this PR, a service can be named i.e.
patroni-batman
orpgdb-myservice
instead of justbatman
ormyservice
.The change is fully backwards-compatible.