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

Extra help when config incorrect #1187

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Dhghomon
Copy link
Contributor

@Dhghomon Dhghomon commented Dec 12, 2023

Resolves #1125 plus adds some extra help when database fails to connect.

(Redoing another PR that also went after the ._is_interactive() part which I see is recently added code)

In case of:

  • Incorrect user, password, or database: adds hint to use edgedb info to find config file location
  • Incorrect tls_cert_data: same message but nicer formatting to compare expected with actual
  • Incorrect port: still hangs but adds message that the CLI will try for the timeout period (usually 30s),
  • Incorrect tls_security: No change needed here as the message already lays out the file location and possible settings

Some before and afters:

Incorrect port

  • Before

Connecting to EdgeDB instance 'anything' at localhost:11700...edgedb error: ClientConnectionFailedError: cannot establish connection for 30s: No connection could be made because the target machine actively refused it. (os error 10061)

  • After

Connecting to EdgeDB instance 'anything' at localhost:11700 (will try up to 30s)...
edgedb error: ClientConnectionFailedError: cannot establish connection for 30s: No connection could be made because the target machine actively refused it. (os error 10061)

Incorrect user

  • Before

Connecting to EdgeDB instance 'anything' at localhost:10700...edgedb error: AuthenticationError: authentication failed
Server traceback:
Traceback (most recent call last):
File "edb/server/protocol/frontend.pyx", line 338, in edb.server.protocol.frontend.FrontendConnection.main
File "edb/server/protocol/binary.pyx", line 951, in authenticate
File "edb/server/protocol/binary.pyx", line 285, in auth
File "edb/server/protocol/frontend.pyx", line 574, in _authenticate
File "edb/server/protocol/frontend.pyx", line 690, in _auth_scram
edb.errors.AuthenticationError: authentication failed

  • After

Connecting to EdgeDB instance 'anything' at localhost:10700 (will try up to 30s)...
Failed to authenticate.
Hint: Use edgedb info to find and check the config for this instance
edgedb error: AuthenticationError: authentication failed
Server traceback:
Traceback (most recent call last):
File "edb/server/protocol/frontend.pyx", line 338, in edb.server.protocol.frontend.FrontendConnection.main
File "edb/server/protocol/binary.pyx", line 951, in authenticate
File "edb/server/protocol/binary.pyx", line 285, in auth
File "edb/server/protocol/frontend.pyx", line 574, in _authenticate
File "edb/server/protocol/frontend.pyx", line 690, in _auth_scram
edb.errors.AuthenticationError: authentication failed

Incorrect password

  • Before

Connecting to EdgeDB instance 'anything' at localhost:10700...edgedb error: AuthenticationError: authentication failed
Server traceback:
Traceback (most recent call last):
File "edb/server/protocol/frontend.pyx", line 338, in edb.server.protocol.frontend.FrontendConnection.main
File "edb/server/protocol/binary.pyx", line 951, in authenticate
File "edb/server/protocol/binary.pyx", line 285, in auth
File "edb/server/protocol/frontend.pyx", line 574, in _authenticate
File "edb/server/protocol/frontend.pyx", line 690, in _auth_scram
edb.errors.AuthenticationError: authentication failed

  • After

Connecting to EdgeDB instance 'anything' at localhost:10700 (will try up to 30s)...
Failed to authenticate.
Hint: Use edgedb info to find and check the config for this instance
edgedb error: AuthenticationError: authentication failed
Server traceback:
Traceback (most recent call last):
File "edb/server/protocol/frontend.pyx", line 338, in edb.server.protocol.frontend.FrontendConnection.main
File "edb/server/protocol/binary.pyx", line 951, in authenticate
File "edb/server/protocol/binary.pyx", line 285, in auth
File "edb/server/protocol/frontend.pyx", line 574, in _authenticate
File "edb/server/protocol/frontend.pyx", line 690, in _auth_scram
edb.errors.AuthenticationError: authentication failed

Incorrect database

  • Before

Connecting to EdgeDB instance 'anything' at localhost:10700...[2023-12-12T02:59:31Z WARN edgedb_tokio::raw::connection] Error received from server: database 'edgedbb' does not exist. Severity: Error. Code: 0x4030005
edgedb error: ClientConnectionFailedError: end of stream while reading message

  • After

Connecting to EdgeDB instance 'anything' at localhost:10700 (will try up to 30s)...
[2023-12-12T02:59:56Z WARN edgedb_tokio::raw::connection] Error received from server: database 'edgedbb' does not exist. Severity: Error. Code: 0x4030005
edgedb error: ClientConnectionFailedError: end of stream while reading message

Incorrect tls_cert_data

  • Before

edgedb error: ClientError: cannot read credentials file C:\Users\mithr\AppData\Local\EdgeDB\config\credentials\anything.json: det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n")

  • After

edgedb error: ClientError: cannot read credentials file C:\Users\mithr\AppData\Local\EdgeDB\config\credentials\anything.json: detected conflicting settings.
tls_ca =
Some(
"-----BEGIN CERTIFICATE-----\nMIIC0zCCAbugAwIBAgIRANoFby9jWEKWg+rIfBNbHxIwDQYJKoZIhvcNAQELBQAw\nGDEWMBQGA1UEAwwNRWRnZURCIFNlcnZlcjAeFw0yMzEyMDYyMTQxMjRaFw00MzAy\nMDUyMTQxMjRaMBgxFjAUBgNVBAMMDUVkZ2VEQiBTZXJ2ZXIwggEiMA0GCSqGSIb3\nDQEBAQUAA4IBDwAwggEKAoIBAQDqPb0sq6MVF4KCnrNisfzpSuigE8qd0vTIUqdj\ntsgyA534V/8jVCSlsy+LNDwEbwC8ChbuhyP65HgTmsdiiMkXHR3/E0g8POqLcm40\n24oTBqtRc4f8SOHHJThcxeLZ2WzgdvEjTJGhet/fR/8Gv4Fz8tClbqISfMkqHOVE\n5ViDKAtlpiGfDxfIrTBlHhuZM3BnD7o9yi+3zh7+aTHPVnbs2lxhh9O/Caa8TCUW\nsFocrEEijQRoIVmk3nzJ8goRZyIIBAY9g/OB06yW9LNGBbvHhNZyeKNQ7nnL8LMJ\nJ2Bpgbibp2itwFGZtrc1mnAnVNvx8CROnSpcQYTnh2AUEei9AgMBAAGjGDAWMBQG\nA1UdEQQNMAuCCWxvY2FsaG9zdDANBgkqhkiG9w0BAQsFAAOCAQEAELhVm4yRpvvG\nK0kyLsSSMZDwSXGbm4MiCFpRktJ04vo7o2j2OPwqxtjgNhmi7Xb8TUshD4dOWqU5\nrSzcGAtnqfCiLu6kqA9k2vfGSn/WiQb0ItpcqtyNQ3QqwOXju7wiTxGqjudhINuf\nXzSqZkBfpdAzpXG1e/PlKAepQ80Q9nP3j7dtmA3KbWDuJ+I1b4oOBNzhQZbXjsxH\n8uuY51TmnupI6TPu+KqVfln1Km5HlPeIKMrdoO0HVaU86+bBx+k0N0in1spOUCbz\nHdk0zWy2iYye2sMhtnsLDJysyID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JysyIDOHEYTMoQ2XakuSiSOZmJvlCCFdrLF5jml5Ab8\nU9Q49+cuzQ==\n-----END CERTIFICATE-----\n",
)

@Dhghomon Dhghomon marked this pull request as ready for review December 12, 2023 02:51
Copy link
Contributor

@raddevon raddevon left a comment

Choose a reason for hiding this comment

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

Love these changes!

seconds if seconds < 1 => format!("{}ms", wait.as_millis()),
seconds => format!("{seconds}s")
};
format!("Connecting to {desc} (will try up to {wait_msg})...\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this telling me the number of retries or the time? I assume it's the time since wait_msg is set to wait.as_secs(), but it's not entirely clear based on the message. I.e., is the next word "times" or "seconds?"

Maybe wait_msg includes "seconds," and if so, ignore this suggestion.

Suggested change
format!("Connecting to {desc} (will try up to {wait_msg})...\n")
format!("Connecting to {desc} (will try for up to {wait_msg} seconds)...\n")

Copy link
Contributor Author

@Dhghomon Dhghomon Dec 12, 2023

Choose a reason for hiding this comment

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

Yeah, it'll be seconds or milliseconds (though far more likely to be seconds), written s or ms (ms if under one second). Could change s to seconds though.

Interestingly during the 30 seconds you can see it trying over and over again if you set the RUST_LOG to something like debug so we could technically put those messages in if it makes sense. It's noisier but the advantage would be that the user gets to see the problem within five seconds instead of twiddling thumbs until the 30 seconds have passed / killing the process.

Here's the output with debug, could pull out those debug messages and print them a bit nicer:

PS C:\rust\edgedb-cli> cargo run
    Finished dev [optimized + debuginfo] target(s) in 0.45s
     Running `target\debug\edgedb.exe`
[2023-12-12T13:58:31Z DEBUG edgedb::version_check] Cached version None
[2023-12-12T13:58:31Z INFO  edgedb_tokio::raw::connection] Connecting via TCP localhost:10757
[2023-12-12T13:58:31Z DEBUG rustyline] PathInfo("C:\\Users\\mithr\\AppData\\Local\\edgedb\\edgeql.history", SystemTime { intervals: 133468273415897816 }, 100)
Connecting to EdgeDB instance 'edgedb_cli' at localhost:10757 (will try up to 30s)...
[2023-12-12T13:58:35Z DEBUG edgedb_tokio::raw::connection] Temporary connection error: ClientConnectionError: No connection could be made because the target machine actively refused it. (os error 10061)
[2023-12-12T13:58:39Z DEBUG edgedb_tokio::raw::connection] Temporary connection error: ClientConnectionError: No connection could be made because the target machine actively refused it. (os error 10061)
[2023-12-12T13:58:43Z DEBUG edgedb_tokio::raw::connection] Temporary connection error: ClientConnectionError: No connection could be made because the target machine actively refused it. (os error 10061)
[2023-12-12T13:58:47Z DEBUG edgedb_tokio::raw::connection] Temporary connection error: ClientConnectionError: No connection could be made because the target machine actively refused it. (os error 10061)
[2023-12-12T13:58:51Z DEBUG edgedb_tokio::raw::connection] Temporary connection error: ClientConnectionError: No connection could be made because the target machine actively refused it. (os error 10061)
[2023-12-12T13:58:56Z DEBUG edgedb_tokio::raw::connection] Temporary connection error: ClientConnectionError: No connection could be made because the target machine actively refused it. (os error 10061)
[2023-12-12T13:59:00Z DEBUG edgedb_tokio::raw::connection] Temporary connection error: ClientConnectionError: No connection could be made because the target machine actively refused it. (os error 10061)
[2023-12-12T13:59:04Z DEBUG edgedb_tokio::raw::connection] Temporary connection error: ClientConnectionError: No connection could be made because the target machine actively refused it. (os error 10061)
edgedb error: ClientConnectionFailedError: cannot establish connection for 30s: No connection could be made because the target machine actively refused it. (os error 10061)
error: process didn't exit successfully: `target\debug\edgedb.exe` (exit code: 1)```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Connecting to an instance without "edgedb" database results in messy error
2 participants