fix: fix datatable setup on RDS (#8450)

* Fix Datatable setup on RDS

* nit

* unused import

* add replication
This commit is contained in:
Diego Imbert
2026-03-19 10:02:41 +00:00
committed by GitHub
parent fd7f0d3da9
commit 446afb5b36
3 changed files with 11 additions and 11 deletions
+9 -2
View File
@@ -972,8 +972,7 @@ async fn setup_custom_instance_pg_database_inner(
GRANT CREATE ON DATABASE \"{dbname}\" TO custom_instance_user;
ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO custom_instance_user;
ALTER ROLE custom_instance_user CREATEROLE;
ALTER ROLE custom_instance_user REPLICATION;"
ALTER ROLE custom_instance_user CREATEROLE;"
))
.await
.map_err(|e| {
@@ -982,6 +981,14 @@ async fn setup_custom_instance_pg_database_inner(
e.to_string(),
))
})?;
if let Err(e) = client
.batch_execute(&format!("ALTER ROLE custom_instance_user REPLICATION;"))
.await
{
tracing::error!("Failed to grant replication permission to custom_instance_user: {e:#}");
}
logs.grant_permissions = "OK".to_string();
drop(client); // /!\ Drop before joining to avoid deadlock
+1 -7
View File
@@ -42,10 +42,7 @@ use windmill_common::{
db::{DbWithOptAuthed, UserDB},
error::{self, Error, JsonResult, Result},
get_database_url,
utils::{
get_custom_pg_instance_password, not_found_if_none, paginate, require_admin, Pagination,
StripPath,
},
utils::{not_found_if_none, paginate, require_admin, Pagination, StripPath},
variables,
worker::{CLOUD_HOSTED, WINDMILL_DIR},
PgDatabase,
@@ -504,12 +501,9 @@ pub async fn get_resource_value_interpolated_internal<'a>(
) -> Result<Option<serde_json::Value>> {
// This is a special syntax to help debugging custom instance databases
if let Some(dbname) = path.strip_prefix("CUSTOM_INSTANCE_DB/") {
let db = db_with_opt_authed.db();
require_super_admin(db_with_opt_authed.db(), &db_with_opt_authed.email()).await?;
let mut pg_creds = PgDatabase::parse_uri(&get_database_url().await?.as_str().await)?;
pg_creds.dbname = dbname.to_string();
pg_creds.password = Some(get_custom_pg_instance_password(&db).await?);
pg_creds.user = Some("custom_instance_user".to_string());
let pg_creds = serde_json::to_value(&pg_creds)
.map_err(|e| Error::internal_err(format!("Error serializing pg creds: {}", e)))?;
return Ok(Some(pg_creds));
@@ -134,8 +134,7 @@
`GRANT CREATE ON DATABASE "${dbname}" TO custom_instance_user;\n` +
'ALTER DEFAULT PRIVILEGES IN SCHEMA public \n' +
' GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES\n TO custom_instance_user;\n' +
'ALTER ROLE custom_instance_user CREATEROLE;\n' +
'ALTER ROLE custom_instance_user REPLICATION;'
'ALTER ROLE custom_instance_user CREATEROLE;'
}
],
status?.error ?? undefined