Closed HaojunRen closed 3 years ago
The key is not allowed to contain "."
Sorry,it is Consul limitation, but if we use MetaData key which contains dot(.), Spring Cloud can help me to resolve this issue? Thanks
@spencergibb this issue difficult to us to resolve, it seems we must replace all "." to "-".
My suggestion is that Spring Cloud 2020 merges tags and current metadatas to final metadata. Example there are two configs spring.cloud.discovery.tag=a.b=1 spring.cloud.discovery.metadata.c=2
the special character metadata can be SET with tag, so the final MetaData Map is a.b=1, c=2.
if tag and metadata configs have the same key, use metadata config
BTE, refer to Consul issus links: https://github.com/hashicorp/consul/issues/8127 https://github.com/hashicorp/consul/issues/4422 https://github.com/codecentric/spring-boot-admin/issues/1456
Are your properties set by Spring Cloud consul or some other means?
Yeah, it seems Consul sidecar does not want to change anything. To our business, MetaData keys are related with our many important outside systems, changing those keys are large workaround to us. so would you please do that enhancement in next 2020 version? That is Spring Cloud fan hope, Many many thanks!!
Sorry, if i discribe not so cleared, i will try it again users can config tags as before like that spring.cloud.discovery.tag=a.b=1,x.y=2 so MetaData are {"a.b=1","x.y=2"}
if he add new format metadata like that spring.cloud.discovery.metadata.c=3
so the final metada is {"a.b=1","x.y=2","c=3"}
if he SET spring.cloud.discovery.tag=a.b=1,x.y=2,c=123 spring.cloud.discovery.metadata.c=3
the final metada still is {"a.b=1","x.y=2","c=3"}
What feature that you want to use depends on metadata?
User has special character to config with tag, no special character to config with new MetaData fomat. Two operations have same result.
What feature that you want to use depends on metadata?
for example, using MetaData to do gray relase or blue-green release, or store customs info, like telephone, email etc, like spring.cloud.discovery.tag=service.version,service.owner.name=Tom,service.owner.email=xyz@google.com
If you just want access to tags via service instance and registration that is already available.
if i config it as tags, getMetadata method return empty in service instance and registration. is that a bug? And those data can be found in getTags method
My Idea is getMetadata can get tags data
It is not a bug. Why do you need it in metadata?
because in hoxton, we config those with tags, and can get those via getMetadata
in 2020, we can accept to change those with metadata config, but our MetaData key have ".", Consul Server Side refuses to those. So I have no idea...
So you could change to use getTags() rather than metadata rather than migrating to use metadata
According to your suggestion, here we have 2 register middlewares : Eureka and Consul. We provides a common module, it has follows logic:
Map<String, String> metadata = instance.getMetadata();
For Eureka it works
But for Consul it doesn't works if using getTags, because getTags is not a spring cloud common method
it should change to
ConsulServiceInstance consulServiceInstance = (ConsulServiceInstance) instance;
List<String> tags = consulServiceInstance.getTags();
Map<String, String> metadata = parseToMetadata(tags);
So the common module will not be so generic, we must change a lot of...
Some business system maybe not use that common module, and I don't how much places shoud do following change
ConsulServiceInstance consulServiceInstance = (ConsulServiceInstance) instance;
List<String> tags = consulServiceInstance.getTags();
Map<String, String> metadata = parseToMetadata(tags);
Would you please add a flag property to enable/disable merging tags to metadata?default value is false, so that use can control that logic by himself
If I set metadata by code as follows:
The exception will throw out, is it an issue?
If that still use tags, works fine