-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Fix catalog tag filter backward compat #4944
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM: will allow to upgrade Consul from versions prior to 1.3.0 without troubles (otherwise, migration is broken)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Aestek does this same issue not affect /health/:service
in the same way?
And thanks for the patch! We'll work out how to release this once we are happy we caught all this issues caused by the tags change.
if len(args.ServiceTag) > 0 { | ||
tags = append(tags, args.ServiceTag) | ||
} | ||
return s.ServiceTagNodes(ws, args.ServiceName, tags) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like it will merge old and new fields...
Assuming that the old field is only set by <1.3 clients who didn't know about the new one I think it will do the job, but that assumption isn't mentioned in comments so I think it will get lost over time!
My marginal preference would be to make the actual logic explicit without that assumption:
if args.TagFilter {
tags := args.ServiceTags
// If there are no tags, fallback to the old singular tag field as this may be an RPC from a client running Consul < 1.3.0
if len(tags) == 0 && len(args.ServiceTag) > 0 {
tags = []string{args.ServiceTag} // Forget the actual type so it might not be this...
}
return s.ServiceTagNodes(ws, args.ServiceName, tags)
}
@banks |
ba64dfd
to
aedc1a1
Compare
@banks I've updated the logic as you suggested |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Datacenter: "dc1", | ||
ServiceName: "db", | ||
ServiceTag: "primary", | ||
ServiceTags: []string{"primary"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: if you made the old and new fields have different values here you could effectively assert the non-merging behaviour I mentioned. As it is the implementation might be taking either or merging them and just happens the duplication doesn't matter. I'm sure it will pass so I can make that tweak when we merge but if you want to do that please do @Aestek, we'll talk about when to merge and release this later today.
Thanks! Yeah So that case was caught because DNS interface tests effectively exercised it already internally - the only real reason I can see that DNS still exercises the old code path was that DNS syntax doesn't easily support multiple tags and so we left the code alone. Had we updated DNS to use @Aestek if you are making another change based on that nitpick comment, how do you feel about updating the comment in the health endpoint to also mention migration just in case we do update DNS and think it's redundant some time later? Minor thing but might be nice. |
aedc1a1
to
c7c66c8
Compare
@banks I've update this so
|
c7c66c8
to
4126de1
Compare
Fix catalog service node filtering (ex /v1/catalog/service/srv?tag=tag1) between agent version <=v1.2.3 and server >=v1.3.0. New server version did not account for the old field when filtering hence request made from old agent were not tag-filtered.
4126de1
to
f582c6f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THanks @Aestek that's great. We'll figure out when to merge this later on.
@Aestek thanks so much for the fix. It's really appreciated. |
@banks Thanks ! |
Fix catalog service node filtering (ex /v1/catalog/service/srv?tag=tag1) between agent version <=v1.2.3 and server >=v1.3.0. New server version did not account for the old field when filtering hence request made from old agent were not tag-filtered.
Fixes: #4922
Fix catalog service node filtering (ex
/v1/catalog/service/service?tag=tag1
) between agent version <=v1.2.3 and server >=v1.3.0.New server version did not account for the old field when filtering hence request made from old agent were not tag-filtered.