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

Commas in Service tags cannot be escaped #1531

Closed
erdanzhang opened this issue Sep 26, 2022 · 2 comments · Fixed by #1532
Closed

Commas in Service tags cannot be escaped #1531

erdanzhang opened this issue Sep 26, 2022 · 2 comments · Fixed by #1532
Labels
type/bug Something isn't working

Comments

@erdanzhang
Copy link
Contributor

Community Note

Per document:
https://www.consul.io/docs/k8s/annotations-and-labels

image

Commas in service tags should be able to be escaped by "". However, when using the K8S deploy template and enabling service mesh (sidecar injection)

template:
    metadata:
      annotations:
        consul.hashicorp.com/service-tags: mid\,dle,com\,ma

The service tag got through Consul API endpoint:

{
    "test-svc": [
        "dle",
        "com\\",
        "ma",
        "mid\\"
    ],
}

Reproduction Steps

Installing Consul helm chart, enable connect inject. And deploy a service by adding the annotation above. By using the Consul catalog API endpoint, we should able to see the reproduced result.

More Context

A similar issue has been address in here:
#719

And a merged PR:
#983

However, the merged code ONLY parses the services tag when running the command sync-catalognot in the controllerinject-connect`.

A possible reasonable solution is to add the following line in control-plane/connect-inject/endpoints_controller.go:1215 to consulTags function:

// consulTags returns tags that should be added to the Consul service and proxy registrations.
func consulTags(pod corev1.Pod) []string {
	var tags []string
	if raw, ok := pod.Annotations[annotationTags]; ok && raw != "" {
		tags = append(tags, parseTags(raw)...)
	}

// Redefine parseTags here or move control-plane/catalog/to-consul/resource.go: parseTags to a common util library
func parseTags(tagsAnno string) []string {

After I made the chaand nge as mentioned above, deploy the image to my k8s cluster, the service tag can now be correctly spilited

@lkysow Hey, Luke Kysow, PR #719 seems to be authored by you, could you please take a look at this issue, and decide if the proposed solution is reasonable? Many thanks!

This is current the blocker for our team to onboard using Consul :)

@kschoche
Copy link
Contributor

Hi @erdanzhang - Thanks for raising this issue to our attention, I've merged the fix into our main branch and it should be part of our upcoming release.
Cheers.
~Kyle

@erdanzhang
Copy link
Contributor Author

@kschoche Thanks for the quick respond and nice fix!!! Look forward to the next release and Consul onboarding!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants