Skip to content

Fix an issue tsh db connect <mongodb> does not give reason on connection errors#34271

Merged
greedy52 merged 3 commits intomasterfrom
STeve/34093_fix_mongo_client_error
Nov 20, 2023
Merged

Fix an issue tsh db connect <mongodb> does not give reason on connection errors#34271
greedy52 merged 3 commits intomasterfrom
STeve/34093_fix_mongo_client_error

Conversation

@greedy52
Copy link
Copy Markdown
Contributor

@greedy52 greedy52 commented Nov 6, 2023

Fixes #34093

Before fix:

$ tsh db connect --db-user not-steve --db-name test self-hosted-mongo-auto
Current Mongosh Log ID:	654956105af843c72720ee2a
Connecting to:		mongodb://localhost:65358/test?serverSelectionTimeoutMS=5000&directConnection=true&tls=true&tlsCertificateKeyFile=%2FUsers%2Fstevehuang%2F.tsh%2Fkeys%2Fteleport.dev.aws.stevexin.me%2FSTeve-db%2Fteleport.dev.aws.stevexin.me%2Fself-hosted-mongo-auto-x509.pem&tlsCAFile=%2FUsers%2Fstevehuang%2F.tsh%2Fkeys%2Fteleport.dev.aws.stevexin.me%2Fcas%2Fteleport.dev.aws.stevexin.me.pem&appName=mongosh+2.0.2
MongoServerSelectionError: connection <monitor> to 127.0.0.1:65358 closed

After fix:

$ tsh db connect --db-user not-steve --db-name test self-hosted-mongo-auto
Current Mongosh Log ID:	654955e278da97e72cc46f5e
Connecting to:		mongodb://localhost:65322/test?serverSelectionTimeoutMS=5000&directConnection=true&tls=true&tlsCertificateKeyFile=%2FUsers%2Fstevehuang%2F.tsh%2Fkeys%2Fteleport.dev.aws.stevexin.me%2FSTeve-db%2Fteleport.dev.aws.stevexin.me%2Fself-hosted-mongo-auto-x509.pem&tlsCAFile=%2FUsers%2Fstevehuang%2F.tsh%2Fkeys%2Fteleport.dev.aws.stevexin.me%2Fcas%2Fteleport.dev.aws.stevexin.me.pem&appName=mongosh+2.0.2
MongoServerSelectionError: error authorizing database access
	please use your Teleport username ("STeve") to connect instead of "not-steve"

changelog: Fix an issue tsh db connect <mongodb> does not give reason on connection errors

@greedy52 greedy52 force-pushed the STeve/34093_fix_mongo_client_error branch from 673ea8f to 4bcfcb0 Compare November 9, 2023 16:51
@greedy52 greedy52 marked this pull request as ready for review November 15, 2023 20:58
@github-actions github-actions Bot requested a review from bl-nero November 15, 2023 20:59
@github-actions github-actions Bot added database-access Database access related issues and PRs size/md labels Nov 15, 2023
Comment thread lib/srv/db/mongodb/engine.go
@greedy52 greedy52 added this pull request to the merge queue Nov 20, 2023
Merged via the queue into master with commit adf2ca3 Nov 20, 2023
@greedy52 greedy52 deleted the STeve/34093_fix_mongo_client_error branch November 20, 2023 16:43
@public-teleport-github-review-bot
Copy link
Copy Markdown

@greedy52 See the table below for backport results.

Branch Result
branch/v12 Failed
branch/v13 Failed
branch/v14 Create PR

github-merge-queue Bot pushed a commit that referenced this pull request Nov 23, 2023
…ction errors (#34271) (#34909)

* Fix an issue `tsh db connect <mongodb>` does not give reason on connection errors

* add ut

* downgrade serverConnected to bool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

database-access Database access related issues and PRs size/md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tsh db connect <mongodb> gives 127.0.0.1:xxxx closed error without any context

4 participants