-
Notifications
You must be signed in to change notification settings - Fork 7
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
acl-controller: Fix creation of namespaces in a partition in 1.12 #72
Conversation
@@ -147,6 +147,7 @@ func TestServiceStateLister_List(t *testing.T) { | |||
} | |||
|
|||
for name, c := range cases { | |||
c := c |
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.
Is this required?
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.
Yes, though it's because I recently added t.Parallel()
to tests in this file (which reduced the test time for this file from ~60s to ~10s on my laptop).
The reason is this gotcha with how Golang closures capture variables (e.g. https://blog.cloudflare.com/a-go-gotcha-when-closures-and-goroutines-collide/). In some cases these tests modify stuff on c
, and that's not okay when these run in parallel since they actually share a reference to c
when they run.
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.
Makes sense. What do you think about adding a comment at least the first time?
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.
Yep. There could be other issues with enabling those tests to run in parallel. I'm monitoring it, and if it causes more instability I can revert back to no parallelism there.
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'd vote for no parallelism and just eat the 60s because guaranteed someone will miss this.
Changes proposed in this PR:
When using Consul 1.12, the controller always creates namespaces in the default partition, even when running the controller in the default partition. This seems to be because the partition is passed as a field, rather than as query parameters.
How I've tested this PR:
I added a unit test, which I've run with 1.11.5+ent and 1.12.0+ent (
go test -count=1 ./controller/ --tags=enterprise -- -enterprise
)I also manually ran the following script with Consul 1.11.5+ent and 1.12.0+ent:
Expand for script
Explanation: This scripts tries to creates two namespaces in partition
part-1
by passing the partition as either a field in the namespace object, or as a query parameter. With Consul 1.11.5+ent, it creates both namespaces inpart-1
, but with Consul 1.12.5+ent it creates only thens-write-options
namespace inpart-1
.With Consul 1.12.0+ent,
With Consul 1.11.5+ent,
How I expect reviewers to test this PR:
👀
Checklist: