spring-cloud / spring-cloud-consul

Spring Cloud Consul
http://cloud.spring.io/spring-cloud-consul/
Apache License 2.0
812 stars 541 forks source link

Removal of "tags as metadata" breaks my gateway include expression #698

Closed lucasoares closed 3 years ago

lucasoares commented 3 years ago

Hello.

This commit removed the ability to use tags as metadata with Consul.

I have more than thousand services registered using tags and my Spring Cloud Gateway have a custom include-expression:

spring:
  cloud:
    gateway:
      discovery:
        locator:
          enabled: false
          include-expression: metadata[prefix] != null and metadata[service_name] != null and metadata[service_host] != null and metadata[service_port] != null and metadata[service_host] != 'custom_host'

With new Spring Cloud Gateway now this expression always results in a empty list. I didn't found any documentation on how to workaround this without having to re-deploy my entire service architecture to register metadata instead tags.

What to do? Is there any documentation about breaking changes on Consul discovery service that I can know about these changes?

I really need a workaround since I can't add metadata on all my services right now.

Sorry if this is the wrong project to create this issue. If so please inform me so I can move it to Spring Cloud Gateway. Thanks

lucasoares commented 3 years ago

If I need to do something like this solution to be able to upgrade Spring Cloud Gateway using consul without re-deploying all my services I will be VERY SAD:

 include-expression: "getTags().?[#this matches '^service_port=.+$'].size() > 0 and getTags().?[#this matches '^service_host=.+$'].size() > 0 and getTags().?[#this matches '^service_name=.+$'].size() > 0 and getTags().?[#this matches '^prefix=.+$'].size() > 0 and getTags().?[#this matches '^service_host=((?!\\$\\{custom_host\\}).)*$'].size() > 0"

getTags() are acessing ConsulServiceInstance#getTags

spencergibb commented 3 years ago

Gateway has nothing to do with the creation of metadata. Here is where we list breaking changes.

lucasoares commented 3 years ago

So it's impossible to keep my architecture intact and update Spring Cloud Gateway without redeploying all my services to register tags as metadata?

Thanks for fast reply @spencergibb

spencergibb commented 3 years ago

See https://github.com/spring-cloud/spring-cloud-consul/issues/699