Skip to content

Commit e0161f5

Browse files
committed
add info log about all config changes
1 parent 25c5f8e commit e0161f5

File tree

1 file changed

+28
-12
lines changed
  • libsql-server/src/http/admin

1 file changed

+28
-12
lines changed

libsql-server/src/http/admin/mod.rs

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -324,26 +324,42 @@ async fn handle_post_config<C>(
324324
}
325325
let store = app_state
326326
.namespaces
327-
.config_store(NamespaceName::from_string(namespace)?)
327+
.config_store(NamespaceName::from_string(namespace.clone())?)
328328
.await?;
329-
let mut config = (*store.get()).clone();
330-
config.block_reads = req.block_reads;
331-
config.block_writes = req.block_writes;
332-
config.block_reason = req.block_reason;
333-
config.allow_attach = req.allow_attach;
334-
config.txn_timeout = req.txn_timeout_s.map(Duration::from_secs);
329+
let mut config_after = (*store.get()).clone();
330+
let config_before = config_after.clone();
331+
config_after.block_reads = req.block_reads;
332+
config_after.block_writes = req.block_writes;
333+
config_after.block_reason = req.block_reason;
334+
config_after.allow_attach = req.allow_attach;
335+
config_after.txn_timeout = req.txn_timeout_s.map(Duration::from_secs);
335336
if let Some(size) = req.max_db_size {
336-
config.max_db_pages = size.as_u64() / LIBSQL_PAGE_SIZE;
337+
config_after.max_db_pages = size.as_u64() / LIBSQL_PAGE_SIZE;
337338
}
338339
if let Some(url) = req.heartbeat_url {
339-
config.heartbeat_url = Some(Url::parse(&url)?);
340+
config_after.heartbeat_url = Some(Url::parse(&url)?);
340341
}
341-
config.jwt_key = req.jwt_key;
342+
config_after.jwt_key = req.jwt_key;
342343
if let Some(mode) = req.durability_mode {
343-
config.durability_mode = mode;
344+
config_after.durability_mode = mode;
344345
}
345346

346-
store.store(config).await?;
347+
store.store(config_after.clone()).await?;
348+
// we better to not log jwt token - so let's explicitly log necessary fields
349+
tracing::info!(
350+
message = "updated db config",
351+
namespace = namespace,
352+
block_writes_before = config_before.block_writes,
353+
block_writes_after = config_after.block_writes,
354+
block_reads_before = config_before.block_reads,
355+
block_reads_after = config_after.block_reads,
356+
allow_attach_before = config_before.allow_attach,
357+
allow_attach_after = config_after.allow_attach,
358+
max_db_pages_before = config_before.max_db_pages,
359+
max_db_pages_after = config_after.max_db_pages,
360+
durability_mode_before = config_before.durability_mode.to_string(),
361+
durability_mode_after = config_after.durability_mode.to_string(),
362+
);
347363

348364
Ok(())
349365
}

0 commit comments

Comments
 (0)