Skip to content

PMM-7896 Updated DB discovery query #34

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

Merged
merged 2 commits into from
Apr 13, 2021
Merged

Conversation

percona-csalguero
Copy link

Updated the database discovery query to list only the databases the current user has access to.
For RDS instances, the original query was returning the rdsadmin database but that's an RDS internal DB and no other users has access to it so, connections were failing.

result = append(result, databaseName)
}

if rows.Err() != nil {
return nil, errors.New(fmt.Sprintln("error retrieving rows:", err))

Choose a reason for hiding this comment

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

🚫 [golangci-lint] reported by reviewdog 🐶
err113: do not define dynamic errors, use wrapped static errors instead: "errors.New(fmt.Sprintln("error retrieving rows:", err))" (goerr113)

Choose a reason for hiding this comment

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

May be fmt.Errorf ?

Copy link
Author

@percona-csalguero percona-csalguero Apr 13, 2021

Choose a reason for hiding this comment

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

I didn't want to change it because upstream is not using newer libraries.
The correct way would be use errors.Wrap. There are other parts where the exporting is comparing error types instead using errors.As, etc, but to not to differ too much from upstream, I didn't want to change them.
If you take a look, it is a copy of the error 2 lines above.

result = append(result, databaseName)
}

if rows.Err() != nil {
return nil, errors.New(fmt.Sprintln("error retrieving rows:", err))

Choose a reason for hiding this comment

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

May be fmt.Errorf ?

FROM pg_database
WHERE datallowconn = true
AND datistemplate = false
AND has_database_privilege(current_user, datname, 'connect')`

Choose a reason for hiding this comment

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

Could you please aline this query? :)

@it-percona-cla
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Carlos Salguero seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@BupycHuk BupycHuk merged commit a8d7282 into master Apr 13, 2021
@BupycHuk BupycHuk deleted the PMM-7896_autodiscover_dbs_rds branch April 13, 2021 12:03
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.

6 participants