Skip to content
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

[NET-9468, NET-9902] Differentiate the ListExportedServicesQuery dependency based on the provided partition #1949

Merged
merged 2 commits into from
Jun 6, 2024

Conversation

nathancoleman
Copy link
Member

@nathancoleman nathancoleman commented Jun 5, 2024

Prior to this change, the template below would result in printing the services exported by the default partition twice.

{{ range exportedServices `default` }}
  ...
{{ end }}

{{ range exportedServices `ap1` }}
  ...
{{ end }}

This is because the String func -- used to uniquely identify a dependency provider -- returned the same value each time and wasn't differentiated based on its arguments. Consul-template would then consider these the same dependency and return the same set of services each time.

The fix is to include the differentiator -- the partition name in this case -- in the unique identity returned by .String() for the dependency. With this change, consul-template correctly identifies the code above as having two different dependencies and thus will create a separate dependency for each partition and make the appropriate calls to Consul.

Note

For use with Consul CE, the provided partition name should be an empty string. This change will still work in that case as <Dependency>.String() will return list.exportedServices().

@nathancoleman nathancoleman requested a review from blake June 5, 2024 15:31
@nathancoleman nathancoleman changed the title Differentiate the ListExportedServicesQuery dependency based on the provided partition [WIP] Differentiate the ListExportedServicesQuery dependency based on the provided partition Jun 5, 2024
Base automatically changed from exported-services-endpoint to main June 5, 2024 20:40
@nathancoleman nathancoleman changed the title [WIP] Differentiate the ListExportedServicesQuery dependency based on the provided partition Differentiate the ListExportedServicesQuery dependency based on the provided partition Jun 5, 2024
@nathancoleman nathancoleman marked this pull request as ready for review June 5, 2024 20:41
@nathancoleman nathancoleman changed the title Differentiate the ListExportedServicesQuery dependency based on the provided partition [NET-9468] Differentiate the ListExportedServicesQuery dependency based on the provided partition Jun 5, 2024
@nathancoleman nathancoleman requested review from a team and removed request for jmurret June 6, 2024 14:26
Copy link
Contributor

@DanStough DanStough left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@nathancoleman nathancoleman merged commit 1b4d1de into main Jun 6, 2024
54 checks passed
@nathancoleman nathancoleman deleted the query-each-partition branch June 6, 2024 15:54
@nathancoleman nathancoleman changed the title [NET-9468] Differentiate the ListExportedServicesQuery dependency based on the provided partition [NET-9468, NET-9902] Differentiate the ListExportedServicesQuery dependency based on the provided partition Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants