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

cli: enhance errors reported upon conn failures #28200

Merged
merged 1 commit into from
Aug 7, 2018

Conversation

knz
Copy link
Contributor

@knz knz commented Aug 2, 2018

Fixes #24788.

Prior to this patch, the various CLI commands were making
a halfhearted attempt at decorating the underlying error with some
troubleshooting instructions.

Unfortunately, this was mixing up situations where the TCP connection
failed outright, those where the security settings were incorrect, and
connections dropped later, after the initial handshake was
successful.

In practice, we've noticed that the troubleshooting steps are rather
different for both kinds of situations. So this patch enhances the
code to clarify what is going on. It attempts to distinguish:

  • TCP connection problem ("check --host vs --advertise-host").
  • secure conn to insecure server ("use --insecure?")
  • invalid TLS settings / TLS auth error ("check credentials").
  • timeouts.
  • connection lost (e.g. conn closed by server).

Release note (cli change): The various cockroach client comments
now better attempt to inform the user about why a connection is failing.

@knz knz requested review from bdarnell and petermattis August 2, 2018 15:07
@knz knz requested a review from a team as a code owner August 2, 2018 15:07
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@knz
Copy link
Contributor Author

knz commented Aug 2, 2018

I'm taking suggestions as to how to best test this.

Copy link
Collaborator

@petermattis petermattis left a comment

Choose a reason for hiding this comment

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

I'm taking suggestions as to how to best test this.

I would look at adapting the infrastructure in cli/cli_test.go. But rather than using cliTest.RunWithArgs, you call cli.Run directly for various commands and flag settings which exercise your new error messages.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

@knz
Copy link
Contributor Author

knz commented Aug 2, 2018

ok thanks will look into it

@knz knz force-pushed the 20180802-enhance-conn-failures branch 2 times, most recently from fec24a7 to 6d2a8d3 Compare August 3, 2018 15:44
@knz
Copy link
Contributor Author

knz commented Aug 3, 2018

Now with tests. RFAL.
I used TCL tests because of the diversity of certs/insecure/non-cockroachdb environments that needed to be tested.

@knz knz force-pushed the 20180802-enhance-conn-failures branch from 6d2a8d3 to 27154cc Compare August 3, 2018 15:53
Copy link
Contributor

@bdarnell bdarnell left a comment

Choose a reason for hiding this comment

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

Reviewed 6 of 6 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/cli/error.go, line 87 at r1 (raw file):

		connFailed := func() error {
			const format = "cannot dial server.\n" +
				"Is the server started already?\n" +

s/started already/running/

Prior to this patch, the various CLI commands were making
a halfhearted attempt at decorating the underlying error with some
troubleshooting instructions.

Unfortunately, this was mixing up situations where the TCP connection
failed outright, those where the security settings were incorrect, and
connections dropped later, after the initial handshake was
successful.

In practice, we've noticed that the troubleshooting steps are rather
different for both kinds of situations. So this patch enhances the
code to clarify what is going on. It attempts to distinguish:

- TCP connection problem ("check --host vs --advertise-host").
- secure conn to insecure server ("use --insecure?")
- invalid TLS settings / TLS auth error ("check credentials").
- timeouts.
- connection lost (e.g. conn closed by server).

Release note (cli change): The various `cockroach` client comments
now better attempt to inform the user about why a connection is failing.
@knz knz force-pushed the 20180802-enhance-conn-failures branch from 27154cc to 0894cd6 Compare August 7, 2018 08:31
@knz knz requested a review from a team August 7, 2018 08:31
Copy link
Contributor Author

@knz knz left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/cli/error.go, line 87 at r1 (raw file):

Previously, bdarnell (Ben Darnell) wrote…

s/started already/running/

Done.

@knz knz added the docs-todo label Aug 7, 2018
@knz
Copy link
Contributor Author

knz commented Aug 7, 2018

thanks!

bors r+

cc @jseldess

craig bot pushed a commit that referenced this pull request Aug 7, 2018
28200: cli: enhance errors reported upon conn failures r=knz a=knz

Fixes #24788.

Prior to this patch, the various CLI commands were making
a halfhearted attempt at decorating the underlying error with some
troubleshooting instructions.

Unfortunately, this was mixing up situations where the TCP connection
failed outright, those where the security settings were incorrect, and
connections dropped later, after the initial handshake was
successful.

In practice, we've noticed that the troubleshooting steps are rather
different for both kinds of situations. So this patch enhances the
code to clarify what is going on. It attempts to distinguish:

- TCP connection problem ("check --host vs --advertise-host").
- secure conn to insecure server ("use --insecure?")
- invalid TLS settings / TLS auth error ("check credentials").
- timeouts.
- connection lost (e.g. conn closed by server).

Release note (cli change): The various `cockroach` client comments
now better attempt to inform the user about why a connection is failing.

Co-authored-by: Raphael 'kena' Poss <[email protected]>
@craig
Copy link
Contributor

craig bot commented Aug 7, 2018

Build succeeded

@craig craig bot merged commit 0894cd6 into cockroachdb:master Aug 7, 2018
@knz knz deleted the 20180802-enhance-conn-failures branch February 14, 2019 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cli: Improve error messages for init
4 participants