-
Notifications
You must be signed in to change notification settings - Fork 323
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
Update MatchesConsul to normalize partitions during comparison. #3284
Conversation
57400ea
to
b44a7b7
Compare
|
||
specialEquality := cmp.Options{ | ||
cmp.FilterPath(func(path cmp.Path) bool { | ||
return path.String() == "Services.Consumers.Partition" |
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.
Exports are kinda weird -- I'd be surprised if they need to be normalized. Was it actually being modified during the wanfed sync?
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.
i didnt check.. based on the conversation with Dhia, i kinda blanket changed everywhere that one could specify a partition.
|
||
specialEquality := cmp.Options{ | ||
cmp.FilterPath(func(path cmp.Path) bool { | ||
return path.String() == "Members.Partition" |
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.
Sameness groups are enterprise-only, so I'd be surprised if they actually sync through wanfed and modify fields. I guess it doesn't hurt to leave this in place, though.
@@ -96,6 +98,7 @@ func TestServiceResolver_MatchesConsul(t *testing.T) { | |||
Targets: []ServiceResolverFailoverTarget{ | |||
{Peer: "failover_peer3"}, | |||
{Partition: "failover_partition3", Namespace: "failover_namespace3"}, | |||
{Partition: "default", Namespace: "default"}, |
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.
To make this a little bit more clear on it being a valid config entry, can we assign another field to this? Perhaps Service
or Peer
? That way, we won't have an empty {}
in the comparison, which isn't really valid data server-side. I suppose the same applies to all of these config entries that are comparing empty {}
, if possible.
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.
good suggestion. ill update the tests to reflect this.
* Update MatchesConsul to normalize partitions during comparison. * Update test cases with valid datasets
Changes proposed in this PR:
When setup as a secondary in WAN federation, Consul migrates config entries from the primary datacenter into the kubernetes secondaries. When the config entries are saved, the
partition
field in the spec of the config entries that have them, gets normalized to the valuedefault
if it was previously""
in Consul Enterprise. CRDs for these resources then constantly re-sync themselves since theMatchesConsul
method, which is responsible for identifying diffs, evaluates the match incorrectly.To normalize this behavior, the comparison operation for the impacted CRDs has been updated so that when the Partition fields are compared, empty strings are normalized to the value
default
. This should ensure that those two values are considered symmetrical and hence should prevent the constant resync of the CRDs into Consul.How I've tested this PR:
How I expect reviewers to test this PR:
Checklist: