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

Allow passing ALPN next protocols down to connect services. Fixes #4466. #9920

Merged
merged 2 commits into from
Mar 26, 2021

Conversation

apollo13
Copy link
Contributor

@banks This should cover the technical aspects of the PR. I am not to happy with the pointer to the nextProto array, but I am not sure how we could pass the default nicely otherwise…

@vercel vercel bot temporarily deployed to Preview – consul March 23, 2021 17:11 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging March 23, 2021 17:11 Inactive
@apollo13 apollo13 force-pushed the connect_proxy_alpn branch from b594e02 to 5b32c2a Compare March 23, 2021 17:15
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging March 23, 2021 17:15 Inactive
@vercel vercel bot temporarily deployed to Preview – consul March 23, 2021 17:15 Inactive
@apollo13 apollo13 force-pushed the connect_proxy_alpn branch from 5b32c2a to 626593f Compare March 23, 2021 17:17
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging March 23, 2021 17:17 Inactive
@vercel vercel bot temporarily deployed to Preview – consul March 23, 2021 17:17 Inactive
@apollo13 apollo13 force-pushed the connect_proxy_alpn branch from 626593f to 01f058c Compare March 23, 2021 17:18
@vercel vercel bot temporarily deployed to Preview – consul March 23, 2021 17:19 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging March 23, 2021 17:19 Inactive
Copy link
Member

@banks banks left a comment

Choose a reason for hiding this comment

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

Thanks for the super quick work!

I realise you're still working on this as the proxy.go change isn't here yet but some minor early feedback before I'm out for the day.

I agree the pointer to string slice is a little odd. It seems like that can just be changed though right? Slices in go are already "pointer" types that can be nil without explicitly pointing to them. Was there something I missed that made it tricky to just use a slice?

connect/service.go Outdated Show resolved Hide resolved
connect/tls.go Outdated Show resolved Hide resolved
@apollo13
Copy link
Contributor Author

I realise you're still working on this as the proxy.go change isn't here yet but some minor early feedback before I'm out for the day.

Well not exactly, proxy.go calls into proxy/config.go which is where I changed the call to use the config.

Was there something I missed that made it tricky to just use a slice?

I do not "know" go, I will read up on slices and try to get it to work.

Thanks for the early feedback, I posted the PR early on because I didn't want to go into the wrong direction…

@apollo13 apollo13 force-pushed the connect_proxy_alpn branch from 01f058c to ed50ff5 Compare March 23, 2021 17:42
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging March 23, 2021 17:43 Inactive
@vercel vercel bot temporarily deployed to Preview – consul March 23, 2021 17:43 Inactive
@apollo13 apollo13 force-pushed the connect_proxy_alpn branch from ed50ff5 to 85c27c8 Compare March 23, 2021 17:54
@vercel vercel bot temporarily deployed to Preview – consul March 23, 2021 17:54 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging March 23, 2021 17:54 Inactive
@apollo13 apollo13 force-pushed the connect_proxy_alpn branch from 85c27c8 to af2165c Compare March 23, 2021 17:55
@vercel vercel bot temporarily deployed to Preview – consul March 23, 2021 17:55 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging March 23, 2021 17:55 Inactive
@apollo13 apollo13 force-pushed the connect_proxy_alpn branch from af2165c to efe90d5 Compare March 23, 2021 18:08
@vercel vercel bot temporarily deployed to Preview – consul March 23, 2021 18:08 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging March 23, 2021 18:08 Inactive
@apollo13 apollo13 requested a review from banks March 23, 2021 18:09
@apollo13
Copy link
Contributor Author

It would be great if one could copy the CI failure out of circle-ci for me. I am not going to login to circle ci when it wants access to my private repos…

Locally make test yields:

make test
--> Checking for other consul instances
==> Building Consul - OSes: linux, Architectures: amd64
Building sequentially with go install
--->   linux/amd64
--> Running go golangci-lint
testutil/server_methods.go:235:7: SA5011: possible nil pointer dereference (staticcheck)
	if s.Config == nil {
	     ^
testutil/server_methods.go:238:7: SA5011: possible nil pointer dereference (staticcheck)
	if s.Config.Ports == nil {
	     ^
testutil/server_methods.go:241:7: SA5011: possible nil pointer dereference (staticcheck)
	if s.Config.Ports.HTTP == 0 {
	     ^
make: *** [GNUmakefile:301: lint] Error 1

but that is unrelated to my changes.

@jsosulska
Copy link
Contributor

Hey @apollo13 - Here's the errors I collected. The first error doesn't provide any feedback. The second is a bit more clear.

# TestACLEndpoint_Login_with_TokenLocality

=== CONT  TestACLEndpoint_Login_with_TokenLocality

At the start of the second test, we have:

=== RUN   TestCoordinate_Update_ACLDeny
=== PAUSE TestCoordinate_Update_ACLDeny
=== CONT  TestCoordinate_Update_ACLDeny
[WARN] freeport: 7 out of 14 pending ports are still in use; something probably didn't wait around for the port to be closed!
[WARN] freeport: 7 out of 7 pending ports are still in use; something probably didn't wait around for the port to be closed!```

And then a bit later on:

## TestCoordinate_Update_ACLDeny

=== CONT  TestCoordinate_Update_ACLDeny
    testagent.go:102: Error while waiting for test agent to start: unavailable. last error: Catalog.ListNodes failed: ACL not found
    retry.go:178: testagent.go:103: TestAgent: unavailable. last error: Catalog.ListNodes failed: ACL not found
        testagent.go:103: TestAgent already started

Hope this helps!

@apollo13
Copy link
Contributor Author

@jsosulska Thanks, can't say it helps much though. I cannot imagine that those are triggered by my changes and cannot reproduce it locally either :/ (I removed the linting check so I can actually run make test)

@banks
Copy link
Member

banks commented Mar 24, 2021

@apollo13 yes those CI failures appear to be unrelated. I'll double check again before we merge of course but we do sadly still have flaky tests some times.

Copy link
Member

@banks banks left a comment

Choose a reason for hiding this comment

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

@apollo13 thanks so much for getting this change in so quickly!

I think this is pretty close to mergeable. The one thing missing as the coverage checker pointed out is that we there are no tests that validate the new behaviour. It's a small plumbing change and a little awkward to test but it would be ideal to have tests to ensure we don't regress this again.

I think the simplest approach would be to just test end-to-end in the proxy package - perhaps with another test along side TestPublicListener in listener.go. That test didn't fail before I think because it's only running a TCP test server.

If we had a second test (TestPublicListenerHTTP?) that used httptest.Server as the "application", ran the proxy as in the existing test but then used svc.HTTPClient to connect to it, I think that should reproduce the failure outlined in the original ticket without this fix. That would then be a good test that the built in proxy is no longer advertising h2 and would still be relatively simpler/cheap to run.

Do you think that's something you'd be able to look into to get this landed?

Thanks again for your effort here!

.changelog/9920.txt Outdated Show resolved Hide resolved
connect/service.go Outdated Show resolved Hide resolved
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging March 25, 2021 16:48 Inactive
@vercel vercel bot temporarily deployed to Preview – consul March 25, 2021 16:48 Inactive
@apollo13 apollo13 force-pushed the connect_proxy_alpn branch from d2b3c37 to 2611fa7 Compare March 25, 2021 17:26
@vercel vercel bot temporarily deployed to Preview – consul March 25, 2021 17:26 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging March 25, 2021 17:26 Inactive
@apollo13
Copy link
Contributor Author

apollo13 commented Mar 25, 2021

@banks I did adjust the existing proxy e2e test to verify that ALPN was not used. I also double checked this by "reverting" parts of my fix so that the proxy would accept h2 via ALPN. Since the changes are rather minimal I just adjusted the test, a new one would have been a 90% duplication.

I did not manage to do the listener test. This is mainly because those use connect.TestService which has it's own TestTLSConfig and as such circumvents most of the things I would like to test. If it is okay for you I'd leave those out.

@apollo13 apollo13 force-pushed the connect_proxy_alpn branch from 2611fa7 to 58dbeeb Compare March 25, 2021 17:31
@vercel vercel bot temporarily deployed to Preview – consul March 25, 2021 17:31 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging March 25, 2021 17:31 Inactive
Copy link
Member

@banks banks left a comment

Choose a reason for hiding this comment

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

Amazing job @apollo13, this looks great to me.

I had a minor suggestion on the test comment wording if you agree and want to use that suggestion or modify it yourself somehow I'll hold of merging it until you do, but it's a nitpick so I'll approve now anyway!

connect/proxy/proxy_test.go Outdated Show resolved Hide resolved
@vercel vercel bot temporarily deployed to Preview – consul March 26, 2021 11:25 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging March 26, 2021 11:25 Inactive
@apollo13
Copy link
Contributor Author

Jupp, the wording change looks good.

@banks banks merged commit c01922d into hashicorp:master Mar 26, 2021
@banks
Copy link
Member

banks commented Mar 26, 2021

Thanks so much for getting this fix in @apollo13!

@banks
Copy link
Member

banks commented Mar 26, 2021

This will be part of Consul 1.10 which will be released in roughly a month or two.

@apollo13 apollo13 deleted the connect_proxy_alpn branch August 31, 2021 20:17
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.

3 participants