feat: add LOAD_ONLY env filter for bots discovery and monitoring
All checks were successful
BotServer CI/CD / build (push) Successful in 10m39s
All checks were successful
BotServer CI/CD / build (push) Successful in 10m39s
This commit is contained in:
parent
9bc8cbe0d6
commit
b5be26591e
2 changed files with 29 additions and 13 deletions
|
|
@ -345,13 +345,13 @@ pub async fn list_buckets(
|
||||||
.filter_map(|b| {
|
.filter_map(|b| {
|
||||||
b.name().map(|name| {
|
b.name().map(|name| {
|
||||||
let name_str = name.to_string();
|
let name_str = name.to_string();
|
||||||
// Only include buckets that start with "gbo-" (MinIO bot source)
|
// Include all .gbai buckets (no gbo- prefix filter)
|
||||||
if !name_str.starts_with("gbo-") {
|
if !name_str.ends_with(".gbai") {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
Some(BucketInfo {
|
Some(BucketInfo {
|
||||||
name: name_str,
|
name: name_str,
|
||||||
is_gbai: name.to_lowercase().ends_with(".gbai"),
|
is_gbai: true,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -916,7 +916,16 @@ async fn start_drive_monitors(
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
register_thread("drive-monitor", "drive");
|
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<String> = 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 {
|
if let Some(s3_client) = &state_for_scan.drive {
|
||||||
match s3_client.list_buckets().send().await {
|
match s3_client.list_buckets().send().await {
|
||||||
Ok(result) => {
|
Ok(result) => {
|
||||||
|
|
@ -925,12 +934,13 @@ async fn start_drive_monitors(
|
||||||
if !name.ends_with(".gbai") {
|
if !name.ends_with(".gbai") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let bot_name = name.strip_suffix(".gbai").unwrap_or(&name);
|
let bot_name = name.strip_suffix(".gbai").unwrap_or(&name).to_string();
|
||||||
let bot_name = if bot_name.starts_with("gbo-") {
|
|
||||||
bot_name.strip_prefix("gbo-").unwrap_or(bot_name)
|
// Filter by LOAD_ONLY if specified
|
||||||
} else {
|
if !load_only.is_empty() && !load_only.contains(&bot_name) {
|
||||||
bot_name
|
trace!("Skipping bot '{}' (not in LOAD_ONLY)", bot_name);
|
||||||
};
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
let exists = {
|
let exists = {
|
||||||
let pool_check = pool_clone.clone();
|
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());
|
info!("Found {} active bots to monitor", bots_to_monitor.len());
|
||||||
|
|
||||||
|
// Apply LOAD_ONLY filter to monitoring as well
|
||||||
|
let load_only_for_monitor: Vec<String> = 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 {
|
for (bot_id, bot_name) in bots_to_monitor {
|
||||||
// Skip bots with reserved system prefixes
|
// Filter by LOAD_ONLY if specified
|
||||||
// gbo-default is a reserved system bot name
|
if !load_only_for_monitor.is_empty() && !load_only_for_monitor.contains(&bot_name) {
|
||||||
if bot_name.starts_with("gbo-") {
|
trace!("Skipping monitoring for bot '{}' (not in LOAD_ONLY)", bot_name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue