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

Fix http2 authority header in single endpoint scenario #13359

Merged
merged 10 commits into from
Sep 29, 2021

Conversation

serathius
Copy link
Member

@serathius serathius commented Sep 17, 2021

Fixes #13192

This doesn't fully fix authority in multiple endpoint scenario, but
should at least fixes single endpoint scenario.

cc @ptabor @tatsuhiro-t @menghanl

@serathius serathius force-pushed the authority branch 4 times, most recently from 15f87be to 8ce6100 Compare September 17, 2021 13:27
@serathius serathius changed the title [Draft] Fix Authority Fix http2 authority header in single endpoint scenario Sep 17, 2021
@serathius serathius force-pushed the authority branch 2 times, most recently from c9afc60 to f83159c Compare September 17, 2021 13:47
server/etcdserver/api/v3rpc/interceptor.go Outdated Show resolved Hide resolved
tests/integration/clientv3/grpc_test.go Outdated Show resolved Hide resolved
client/v3/client.go Show resolved Hide resolved
client/v3/client.go Show resolved Hide resolved
@serathius serathius force-pushed the authority branch 2 times, most recently from d6fbce2 to 171cca3 Compare September 17, 2021 14:34
@codecov-commenter
Copy link

Codecov Report

Merging #13359 (97756e3) into main (c2937d7) will increase coverage by 31.81%.
The diff coverage is n/a.

❗ Current head 97756e3 differs from pull request most recent head 171cca3. Consider uploading reports for the commit 171cca3 to get more accurate results
Impacted file tree graph

@@             Coverage Diff             @@
##             main   #13359       +/-   ##
===========================================
+ Coverage   39.49%   71.31%   +31.81%     
===========================================
  Files         460      453        -7     
  Lines       39141    38856      -285     
===========================================
+ Hits        15459    27709    +12250     
+ Misses      22009     9114    -12895     
- Partials     1673     2033      +360     
Flag Coverage Δ
all 71.31% <ø> (+31.81%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
raft/quorum/quorum.go 0.00% <0.00%> (-100.00%) ⬇️
raft/tracker/state.go 0.00% <0.00%> (-100.00%) ⬇️
client/pkg/v3/tlsutil/cipher_suites.go 0.00% <0.00%> (-100.00%) ⬇️
client/pkg/v3/transport/sockopt_unix.go 0.00% <0.00%> (-100.00%) ⬇️
client/pkg/v3/transport/timeout_dialer.go 0.00% <0.00%> (-100.00%) ⬇️
client/pkg/v3/srv/srv.go 0.00% <0.00%> (-89.42%) ⬇️
client/pkg/v3/types/set.go 19.00% <0.00%> (-74.00%) ⬇️
client/pkg/v3/transport/sockopt.go 11.76% <0.00%> (-70.59%) ⬇️
raft/util.go 25.58% <0.00%> (-62.02%) ⬇️
raft/quorum/voteresult_string.go 0.00% <0.00%> (-60.00%) ⬇️
... and 352 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c2937d7...171cca3. Read the comment docs.

@serathius
Copy link
Member Author

Pushed original fix that uses first endpoint but with huge integration tests rewrite. Needed to rewrite tests to remove hacks that caused problems with testing authority. Those hacks are:

  • Using bridge in integration tests. Integration tests use unix bridge to allow connection manipulation in some tests. I made bridge optional, so only it's only enabled in tests that require it.
  • Only using unix socket in integration tests. Integration tests used only unix socket to remove the need to garbage collect TCP sockets. I added option to enable TCP connections. This is required to integration tests as Unix socket are not officially supported.

Please review new test suites that should cover all possible client endpoint configurations. We still cant cover all cases in https://github.com/grpc/grpc/blob/master/doc/naming.md but as we add more supported names adding them should be much easier.

I decided to use the old fix to confirm that new tests work. I expect that before merging this PR I will try to fix case with multiple endpoints.

@serathius serathius force-pushed the authority branch 4 times, most recently from 2051bc7 to 4ad129d Compare September 28, 2021 13:53
@serathius
Copy link
Member Author

As discussed in #13192 (comment) etcd never supported correct authority in multiple endpoint scenario. This PR restores behavior of etcd v3.4 where first endpoint is used to determine authority header.

This PR should be good to review when tests pass.
PTAL @ptabor

@serathius serathius force-pushed the authority branch 3 times, most recently from 744fa4a to 21dd633 Compare September 28, 2021 14:31
client/v3/client.go Show resolved Hide resolved
pkg/grpc_testing/recorder.go Outdated Show resolved Hide resolved
tests/integration/cluster.go Outdated Show resolved Hide resolved
@@ -153,6 +159,10 @@ type ClusterConfig struct {

// UseIP is true to use only IP for gRPC requests.
UseIP bool
// UseBridge adds bridge between client and grpc server. Should be used in tests that
// want to manipulate connection or require connection not breaking despite server stop/restart.
UseBridge bool
Copy link
Contributor

Choose a reason for hiding this comment

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

As this was previous default and majority of tests got to be changed to get True supplied here explicitly,
have you considered making it WithoutBridge or NoBridge setting to let opt-in for the new behaviour ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Using WithoutBridge would require less changes/work, but I don't think it would be better. I think that enabling bridge is very bad default, it is not as transparent as it might seem. It changes how broken connections are handled hiding some issues which we would want to fix. It also forces integration tests to go through unix socket, which is not officially supported (you cannot bind etcd server to unix socket). This makes maintaining integration and e2e tests much harder, as it increases differences between two environments. When something breaks you don't know if this is specific to integration test environment or etcd logic itself.

I think we should strive to have integration and e2e tests be almost identical in setup, differing only in what is executed underneath (etcdctl binary in e2e and client library in integration). This way it is easy to attribute failures to etcd or environment. Using bridges as a common denominator creates unnecessary complexity, causing us to waste time on fixing integration test code instead of focusing on etcd itself.

Copy link
Contributor

Choose a reason for hiding this comment

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

SG.

Does it mean, there is a follow-up TODO to check which of the existing tests would pass with 'False' ?

Copy link
Member Author

@serathius serathius Sep 29, 2021

Choose a reason for hiding this comment

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

I have only passed "true" only in tests that were failing, so I think this should be done. Only think it that there might be difference between what test was intended to test and it's implementation. Possibly if we changed implementation of some tests we could further reduce usage of bridge, but I don't think profit from this would outweigh amount of work that this would require us to invest.

I think it would make sense to propose rewrite of e2e/integration tests to unified framework and slowly migrate existing tests there, case by case. Removing bridge could be done at the same time and results would be more beneficial (halved amount of easier to debug tests).

Copy link
Contributor

@ptabor ptabor left a comment

Choose a reason for hiding this comment

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

grpcproxy: TestV3KVInflightRangeRequests seems to be continuesly failing (tried 2 retries).

@serathius serathius force-pushed the authority branch 2 times, most recently from 1ff4747 to 1cd1f57 Compare September 29, 2021 10:10
Copy link
Contributor

@ptabor ptabor left a comment

Choose a reason for hiding this comment

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

Please edit the changelog with the new URL schema:
https://github.com/etcd-io/etcd/blob/main/CHANGELOG-3.5.md

@serathius
Copy link
Member Author

Done

@ptabor ptabor merged commit f3cfe0f into etcd-io:main Sep 29, 2021
@serathius serathius deleted the authority branch June 15, 2023 20:39
chaochn47 added a commit to chaochn47/etcd that referenced this pull request Oct 25, 2023
…point scenario

Signed-off-by: Chao Chen <chaochn@amazon.com>
chaochn47 added a commit to chaochn47/etcd that referenced this pull request Oct 26, 2023
…point scenario

Signed-off-by: Chao Chen <chaochn@amazon.com>
chaochn47 added a commit to chaochn47/etcd that referenced this pull request Oct 26, 2023
…point scenario

Signed-off-by: Chao Chen <chaochn@amazon.com>
chaochn47 added a commit to chaochn47/etcd that referenced this pull request Oct 27, 2023
…point scenario

Signed-off-by: Chao Chen <chaochn@amazon.com>
chaochn47 added a commit to chaochn47/etcd that referenced this pull request Nov 22, 2023
…point scenario

Signed-off-by: Chao Chen <chaochn@amazon.com>
chaochn47 added a commit to chaochn47/etcd that referenced this pull request Nov 22, 2023
…point scenario

Signed-off-by: Chao Chen <chaochn@amazon.com>
chaochn47 added a commit to chaochn47/etcd that referenced this pull request Nov 22, 2023
…point scenario

Signed-off-by: Chao Chen <chaochn@amazon.com>
ahrtr added a commit that referenced this pull request Nov 22, 2023
…ty-header-fix

[3.4] backport #13359 Fix http2 authority header in single endpoint scenario
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

etcd client v3 v3.5.0 sends invalid :authority header field value
3 participants