spring-cloud-consul icon indicating copy to clipboard operation
spring-cloud-consul copied to clipboard

Allow for consecutive dashes in normalizeForDns

Open jpuigsegur opened this issue 8 years ago • 5 comments

This is a question regarding the following code:

https://github.com/spring-cloud/spring-cloud-consul/blob/master/spring-cloud-consul-discovery/src/main/java/org/springframework/cloud/consul/serviceregistry/ConsulAutoRegistration.java#L154

It seems that all non letters or numbers are transalated into dashes (SEPARATOR) and also that several contigous dashes are translated into a single dash. We intended to register in consul a spring boot service with a name that contains two contigous dashes, i.e. for example: service--test and we found it was not possible. Since using other tools this name can be registered to Consul without problems (at least that we could see), therefore we are wondering what is the purpose of the normalizeForDns logic in spring.cloud.consul.

Thanks!

jpuigsegur avatar Jul 07 '17 17:07 jpuigsegur

Consul runs a dns server. Those rules are for dns names, otherwise, they won't be available via dns.

spencergibb avatar Jul 07 '17 17:07 spencergibb

Ok. Thanks. I've found it well explainted in https://www.consul.io/docs/agent/services.html#service-and-tag-names-with-dns However, does this include also collapsing two consecutive dashes? I haven't tested it but it looks like a name like "service--test" would be legal.

jpuigsegur avatar Jul 08 '17 09:07 jpuigsegur

I believe I ported that test from consul. Let me know if that is valid in consul and we can change.

spencergibb avatar Jul 12 '17 20:07 spencergibb

We have a service registered with the name "aif2-gen--vip" and I can ping it on the Consul DNS domain:

> ping aif2-gen--vip.service.testaws.discovery

Pinging aif2-gen--vip.service.testaws.discovery [xxx.xxx.xxx.xxx] with 32 bytes of data:
Reply from xxx.xxx.xxx.xxx: bytes=32 time=70ms TTL=52
[...]

However I haven't found the code where consul checks whether a name is compliant or not ...

jpuigsegur avatar Jul 13 '17 07:07 jpuigsegur

Thanks for the response.

spencergibb avatar Jul 18 '17 22:07 spencergibb