From bc93d8f5c1c2289026850cb8eba8d41403de8fbd Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 3 May 2023 10:34:06 +0100 Subject: [PATCH 1/3] Improve connection failure feedback when using API client --- api/client/client.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/api/client/client.go b/api/client/client.go index f036b37f4db3d..7fc5acd16e2ee 100644 --- a/api/client/client.go +++ b/api/client/client.go @@ -597,7 +597,16 @@ func (c *Config) CheckAndSetDefaults() error { PermitWithoutStream: true, })) if !c.DialInBackground { - c.DialOpts = append(c.DialOpts, grpc.WithBlock()) + c.DialOpts = append( + c.DialOpts, + // Provides additional feedback on connection failure, otherwise, + // users will only receive a `context deadline exceeded` error when + // c.DialInBackground == false. + // + // grpc.WithReturnConnectionError implies grpc.WithBlock which is + // necessary connection route selection to work properly. + grpc.WithReturnConnectionError(), + ) } return nil } From 330fe16c552532f5f81f3836f27b6d61cba6aa12 Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 3 May 2023 10:34:50 +0100 Subject: [PATCH 2/3] SPAG in comment --- api/client/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/client/client.go b/api/client/client.go index 7fc5acd16e2ee..63295e19b7cab 100644 --- a/api/client/client.go +++ b/api/client/client.go @@ -604,7 +604,7 @@ func (c *Config) CheckAndSetDefaults() error { // c.DialInBackground == false. // // grpc.WithReturnConnectionError implies grpc.WithBlock which is - // necessary connection route selection to work properly. + // necessary for connection route selection to work properly. grpc.WithReturnConnectionError(), ) } From b52241a439d9089751fe9be5de339058baae2fcb Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 3 May 2023 16:26:49 +0100 Subject: [PATCH 3/3] Remove unnecessary line from API client docs --- docs/pages/api/automatically-register-agents.mdx | 7 ------- docs/pages/api/rbac.mdx | 7 ------- 2 files changed, 14 deletions(-) diff --git a/docs/pages/api/automatically-register-agents.mdx b/docs/pages/api/automatically-register-agents.mdx index 1b2f610eed4cf..30292b26b65a5 100644 --- a/docs/pages/api/automatically-register-agents.mdx +++ b/docs/pages/api/automatically-register-agents.mdx @@ -799,9 +799,6 @@ func newTokenDemoApp() *tokenDemoApp { t, err := teleport.New(ctx, teleport.Config{ Addrs: []string{proxyAddr}, Credentials: []teleport.Credentials{creds}, - DialOpts: []grpc.DialOption{ - grpc.WithReturnConnectionError(), - }, }) if err != nil { panic(err) @@ -830,10 +827,6 @@ up an API client. Our plugin initializes a Teleport client by calling `client.Credentials` to call `client.New`, which connects to the Teleport Proxy Service specified in the `Addrs` field using the provided identity file. -In this example, we are passing the `grpc.WithReturnConnectionError()` function -call to `client.New`, which instructs the gRPC client to return more detailed -connection errors. - This program does not validate your credentials or Teleport cluster address. diff --git a/docs/pages/api/rbac.mdx b/docs/pages/api/rbac.mdx index 824cb0ca40d1d..8d09ff8a7c52b 100644 --- a/docs/pages/api/rbac.mdx +++ b/docs/pages/api/rbac.mdx @@ -748,9 +748,6 @@ func main() { teleport, err := client.New(ctx, client.Config{ Addrs: []string{proxyAddr}, Credentials: []client.Credentials{creds}, - DialOpts: []grpc.DialOption{ - grpc.WithReturnConnectionError(), - }, }) if err != nil { panic(err) @@ -783,10 +780,6 @@ initializes a Teleport client by calling `client.LoadIdentityFile` to obtain a `client.New`, which connects to the Teleport Proxy Service specified in the `Addrs` field using the provided identity file. -In this example, we are passing the `grpc.WithReturnConnectionError()` function -call to `client.New`, which instructs the gRPC client to return more detailed -connection errors. - This program does not validate your credentials or Teleport cluster address.