-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
clientv3: Set authority used in cert checks to host of endpoint #11184
Conversation
a35b10a
to
507f680
Compare
} | ||
} | ||
|
||
func (tc *transportCredential) OverrideServerName(serverNameOverride string) error { | ||
return tc.gtc.OverrideServerName(serverNameOverride) | ||
} | ||
|
||
func (tc *transportCredential) Dialer(ctx context.Context, dialEp string) (net.Conn, error) { |
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.
So, gRPC first calls Dialer
and by the time it calls, ClientHandshake
, the remote address will always have been populated in addrToEndpoint
, right?
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.
Right, here's the dial call: https://github.com/grpc/grpc-go/blob/45bd2846a34b039c5f1e69b7202f118687156b34/internal/transport/http2_client.go#L167 and below it is the ClientHandshake call: https://github.com/grpc/grpc-go/blob/45bd2846a34b039c5f1e69b7202f118687156b34/internal/transport/http2_client.go#L212
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.
And here's where the authority gets set: https://github.com/grpc/grpc-go/blob/230def769105c46b2e597578b23002a6ac159dde/clientconn.go#L1142.
We're basically just trying to get the authority set to an appropriate value for each endpoint instead of having a single value for the entire set of endpoints.
507f680
to
c2702da
Compare
|
||
// Dialer dials a endpoint using net.Dialer. | ||
// Context cancelation and timeout are supported. | ||
func Dialer(ctx context.Context, dialEp string) (net.Conn, error) { |
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.
Nice clean-up by moving code here!
c2702da
to
97388ce
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.
lgtm, thanks for the quick fix!
Great, let's hold off for just a bit before we merge to get feedback from the grpc team. |
Thanks for the quick fix! Implementation looks very clean. |
Merging this to master. I'd like to improve test coverage before we backport to 3.4. |
…-origin-release-3.4 Automated cherry pick of #11184
…-origin-release-3.3 Automated cherry pick of #11184
…after bumping grpc to 1.26.0.
This bumps the etcd dependency in order to pull in github.com/etcd-io/etcd/pull/11184 which is required to fix a gRPC load balancer issue when using a k8s service name to connect to etcd. Fixes: #9791 Signed-off-by: Thomas Graf <thomas@cilium.io>
This bumps the etcd dependency in order to pull in github.com/etcd-io/etcd/pull/11184 which is required to fix a gRPC load balancer issue when using a k8s service name to connect to etcd. Fixes: #9791 Signed-off-by: Thomas Graf <thomas@cilium.io>
[ upstream commit 26e3ca0 ] This bumps the etcd dependency in order to pull in github.com/etcd-io/etcd/pull/11184 which is required to fix a gRPC load balancer issue when using a k8s service name to connect to etcd. Fixes: #9791 Signed-off-by: Thomas Graf <thomas@cilium.io> Signed-off-by: Martynas Pumputis <m@lambda.lt>
[ upstream commit 26e3ca0 ] This bumps the etcd dependency in order to pull in github.com/etcd-io/etcd/pull/11184 which is required to fix a gRPC load balancer issue when using a k8s service name to connect to etcd. Fixes: #9791 Signed-off-by: Thomas Graf <thomas@cilium.io> Signed-off-by: Martynas Pumputis <m@lambda.lt>
…after bumping grpc to 1.26.0. Signed-off-by: Chao Chen <chaochn@amazon.com>
…after bumping grpc to 1.26.0. Signed-off-by: Chao Chen <chaochn@amazon.com>
…after bumping grpc to 1.26.0. Signed-off-by: Chao Chen <chaochn@amazon.com>
Backport [3.4] clientV3: simplify grpc dialer usage. Remove workaround #11184 after bumping grpc to 1.26.0.
Fixes #11180
This is a workaround for the gPRC load balancer, which currently uses the "service name" (which the etcd client was setting to the 1st endpoint's hostname or IP) as authority for all credential checks for all the endpoints it load balances against, which does not work well for configurations where etcd servers use a Subject Alternative Names in their certs set to their hostname or IP. We previously added a workaround to fix this problem for IPs (db61ee1) but not hostnames.
The workaround keeps track of the endpoints the load balancer dials and overwrites the authority in
ClientHandshake
before the cert checks are performed so that the authority is always the host of the endpoint that the client was originally configured with. For example, if a client is configured with:The authorities of the endpoints will now be
member1.etcd.xyz
,member2.etcd.xyz
andmember3.etcd.xyz
respectively. Previously, the authority ofmember1.etcd.xyz
was used for all endpoints.I've manually verified with etcdctl that this does result in the correct authority being used in DNS name SAN cert checks.
@gyuho @jingyih @wenjiaswe