From b5be26591efff17884617bc0b4718459eed8e52b Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Thu, 9 Apr 2026 23:15:54 -0300 Subject: [PATCH] feat: add LOAD_ONLY env filter for bots discovery and monitoring --- src/drive/mod.rs | 6 +++--- src/main_module/bootstrap.rs | 36 ++++++++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/drive/mod.rs b/src/drive/mod.rs index 2ef432f3..b692c482 100644 --- a/src/drive/mod.rs +++ b/src/drive/mod.rs @@ -345,13 +345,13 @@ pub async fn list_buckets( .filter_map(|b| { b.name().map(|name| { let name_str = name.to_string(); - // Only include buckets that start with "gbo-" (MinIO bot source) - if !name_str.starts_with("gbo-") { + // Include all .gbai buckets (no gbo- prefix filter) + if !name_str.ends_with(".gbai") { return None; } Some(BucketInfo { name: name_str, - is_gbai: name.to_lowercase().ends_with(".gbai"), + is_gbai: true, }) }) }) diff --git a/src/main_module/bootstrap.rs b/src/main_module/bootstrap.rs index a4742f37..9e537150 100644 --- a/src/main_module/bootstrap.rs +++ b/src/main_module/bootstrap.rs @@ -916,7 +916,16 @@ async fn start_drive_monitors( tokio::spawn(async move { register_thread("drive-monitor", "drive"); - // Step 1: Discover bots from S3 buckets (gbo-*.gbai) and auto-create missing + // Get LOAD_ONLY from env to filter which bots to load + let load_only: Vec = std::env::var("LOAD_ONLY") + .ok() + .map(|v| v.split(',').map(|s| s.trim().to_string()).collect()) + .unwrap_or_default(); + if !load_only.is_empty() { + info!("LOAD_ONLY filter active: {:?}", load_only); + } + + // Step 1: Discover bots from S3 buckets (*.gbai) and auto-create missing if let Some(s3_client) = &state_for_scan.drive { match s3_client.list_buckets().send().await { Ok(result) => { @@ -925,12 +934,13 @@ async fn start_drive_monitors( if !name.ends_with(".gbai") { continue; } - let bot_name = name.strip_suffix(".gbai").unwrap_or(&name); - let bot_name = if bot_name.starts_with("gbo-") { - bot_name.strip_prefix("gbo-").unwrap_or(bot_name) - } else { - bot_name - }; + let bot_name = name.strip_suffix(".gbai").unwrap_or(&name).to_string(); + + // Filter by LOAD_ONLY if specified + if !load_only.is_empty() && !load_only.contains(&bot_name) { + trace!("Skipping bot '{}' (not in LOAD_ONLY)", bot_name); + continue; + } let exists = { let pool_check = pool_clone.clone(); @@ -987,10 +997,16 @@ async fn start_drive_monitors( info!("Found {} active bots to monitor", bots_to_monitor.len()); + // Apply LOAD_ONLY filter to monitoring as well + let load_only_for_monitor: Vec = std::env::var("LOAD_ONLY") + .ok() + .map(|v| v.split(',').map(|s| s.trim().to_string()).collect()) + .unwrap_or_default(); + for (bot_id, bot_name) in bots_to_monitor { - // Skip bots with reserved system prefixes - // gbo-default is a reserved system bot name - if bot_name.starts_with("gbo-") { + // Filter by LOAD_ONLY if specified + if !load_only_for_monitor.is_empty() && !load_only_for_monitor.contains(&bot_name) { + trace!("Skipping monitoring for bot '{}' (not in LOAD_ONLY)", bot_name); continue; }