From 75d6ba13d88927c17849c0153f8aed165bf47ee9 Mon Sep 17 00:00:00 2001 From: NoOverflow Date: Sun, 21 Apr 2024 16:19:21 +0200 Subject: [PATCH] Fix service account requiring access to every resource to delete a database --- src/main.rs | 2 +- src/routes/delete_database.rs | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3f1960a..1e74609 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,7 +37,7 @@ fn setup_logger() -> Result<(), log::SetLoggerError> { }) .level(if cfg!(debug_assertions) { // TODO: Add a flag to enable debug logging - log::LevelFilter::Info + log::LevelFilter::Debug } else { log::LevelFilter::Debug }) diff --git a/src/routes/delete_database.rs b/src/routes/delete_database.rs index 69d6c3e..d52b84a 100644 --- a/src/routes/delete_database.rs +++ b/src/routes/delete_database.rs @@ -38,9 +38,19 @@ async fn delete_database( .as_str(), ), //.labels(format!("app.kubernetes.io/managed-by=Moonscale").as_str() ) - .await?; + .await; - for item in list.items { + if list.is_err() { + warn!( + "Failed to list resources while deleting instance {} ({}/{})", + instance, + ar.kind, + list.err().unwrap() + ); + continue; + } + + for item in list.unwrap().items { let name = item.name_any(); let ns = item.metadata.namespace.map(|s| s + "/").unwrap_or_default();