-
Notifications
You must be signed in to change notification settings - Fork 129
Revamp MotherDuck settings and secret management #668
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
Conversation
645dbd1
to
2c53ebd
Compare
f43c504
to
4b9eb9c
Compare
448567c
to
d822314
Compare
We were checking ret instead of `errno` for the error codes. That does not work on Linux at least. `ret` is always -1 there. So the additional background workers would continuously restart. This also uses the %m in other cases instead of manually calling `strerror`.
In #668 we changed the configuration of MotherDuck tokens to use `FOREIGN SERVER` + `USER MAPPING` under the hood, along with some helper functions for the most common usages to get people started. In this PR, we align our secrets management with the same mechanism. That way different PG users can use different S3 tokens to connect to the same bucket. We also introduce two helper functions `create_simple_secret` and `create_azure_secret` for the most basic usage. We are now validating secrets using DuckDB directly and store whatever the user provides as long as it leads to a valid secret creation. This allow to support virtually any kind of secrets type and their options that DuckDB supports. Since `SERVER` options are visible to any PG user, the sensitive ones such as `connection_string`, `secret`, `session_token` and `token` are prohibited to in its definition and must be stored in the `USER MAPPING`. DuckDB secrets are created by concatenating `SERVER` and `USER MAPPING` options (if they exists). Implements #683 Fixes #104
Do we support SCOPE option? If not, I could help implement. |
It definitely should. It now validates the options with duckdb. If it doesn't in practice then there's a bug. |
Manually creating the server with option is working. But we didn't expose it through the udf
|
The idea was that create_simple_secret was only for the most simple usecases. And then have more complicated ones use the regular create server syntax. I guess scope might be common enough that it warrants being an argument in create_simple_secret. |
By the way, the foreign data wrapper DuckDB is not granted to normal users. So only superusers are able to create secrets, while normal users can only utilize them. Is this by design, or can we loosen the permissions? Also, normal user can see secrets by |
Revamp MotherDuck settings and secret management
This PR removes any GUC setting for MotherDuck and replaces it with a combination of
SERVER
andUSER MAPPING
for a newly implementedpg_duckdb
Foreign Data Wrapper.New MotherDuck setup:
Users may now define one (and at most one)
SERVER
formotherduck
:Once the
SERVER
is created, for MotherDuck to be enabled, it needs at least oneUSER MAPPING
:Removed GUC settings:
The following GUC settings were thus removed and are now obsolete:
motherduck_enabled
: now implied by aSERVER
andUSER MAPPING
motherduck_token
: now defined in aUSER MAPPING
motherduck_postgres_database
: now implied by the database in which theSERVER
&USER MAPPING
are definedmotherduck_default_database
: now defined as an option of themotherduck
serverConvenience function:
In order to enable MotherDuck support easily, we also provide the following helper: