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

client: option to surface connection errors to callers #3430

Merged
merged 3 commits into from
Apr 9, 2020

Conversation

sethp-nr
Copy link
Contributor

@sethp-nr sethp-nr commented Mar 6, 2020

This commit allows blocking clients to receive a more informative error
message than "context deadline exceeded", which is especially helpful in
tracking down persistent client misconfiguration (such as an invalid TLS
certificate, an invalid server that's refusing connections, etc.)

This commit allows blocking clients to receive a more informative error
message than "context deadline exceeded", which is especially helpful in
tracking down persistent client misconfiguration (such as an invalid TLS
certificate, an invalid server that's refusing connections, etc.)
Rather than introducing a sudden interface change, provide an option for
consumers to opt in to the new interface.
@dfawley dfawley self-assigned this Mar 12, 2020
@dfawley dfawley added the Type: Feature New features or improvements in behavior label Mar 13, 2020
@dfawley dfawley added this to the 1.29 Release milestone Mar 13, 2020
dialoptions.go Outdated
// WithReturnLastError returns a DialOption which makes the client connection
// return the last connection error that occurred instead of a context.DeadlineExceeded error.
// Implies WithBlock()
func WithReturnLastError() DialOption {
Copy link
Member

Choose a reason for hiding this comment

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

Please add an experimental tag for now (see other experimental dial options).

dialoptions.go Outdated
@@ -298,6 +299,16 @@ func WithBlock() DialOption {
})
}

// WithReturnLastError returns a DialOption which makes the client connection
// return the last connection error that occurred instead of a context.DeadlineExceeded error.
Copy link
Member

Choose a reason for hiding this comment

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

Please clarify that this returns the connection error string in addition to the context error, not instead of the context error.

dialoptions.go Outdated
@@ -298,6 +299,16 @@ func WithBlock() DialOption {
})
}

// WithReturnLastError returns a DialOption which makes the client connection
Copy link
Member

Choose a reason for hiding this comment

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

Regarding the name, WithReturnConnectionError is preferable to us.

Additionally, clarify documentation around what exactly it does.
@sethp-nr sethp-nr marked this pull request as ready for review March 13, 2020 19:20
@easwars easwars modified the milestones: 1.29 Release, 1.30 Release Apr 8, 2020
@dfawley
Copy link
Member

dfawley commented Apr 9, 2020

Thank you for the PR!

@dfawley dfawley merged commit b02de00 into grpc:master Apr 9, 2020
@sethp-nr sethp-nr deleted the fix/optional-connection-errors branch April 10, 2020 18:01
case err == nil || !cc.dopts.returnLastError:
conn, err = nil, ctx.Err()
default:
conn, err = nil, fmt.Errorf("%v: %v", ctx.Err(), err)
Copy link

Choose a reason for hiding this comment

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

Wouldn't it be better for the second %v to be %w here, so the error is wrapped and thus available for introspection?

Copy link
Member

Choose a reason for hiding this comment

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Feature New features or improvements in behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants