From 24106ea8da0d84c2a722b5cb21ad89ecf127ff11 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 16 Mar 2026 15:56:15 -0700 Subject: [PATCH] Load tier backends from master config --- seaweed-volume/src/server/heartbeat.rs | 102 +++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/seaweed-volume/src/server/heartbeat.rs b/seaweed-volume/src/server/heartbeat.rs index 22760671c..2e69b05ab 100644 --- a/seaweed-volume/src/server/heartbeat.rs +++ b/seaweed-volume/src/server/heartbeat.rs @@ -15,6 +15,7 @@ use super::grpc_client::{build_grpc_endpoint, GRPC_MAX_MESSAGE_SIZE}; use super::volume_server::VolumeServerState; use crate::pb::master_pb; use crate::pb::master_pb::seaweed_client::SeaweedClient; +use crate::remote_storage::s3_tier::{S3TierBackend, S3TierConfig}; use crate::storage::store::Store; use crate::storage::types::NeedleId; @@ -198,6 +199,7 @@ async fn check_with_master(config: &HeartbeatConfig, state: &Arc) -> bool { + value + .map(|v| { + matches!( + v.trim().to_ascii_lowercase().as_str(), + "1" | "t" | "true" | "y" | "yes" | "on" + ) + }) + .unwrap_or(true) +} + /// Collect volume information into a Heartbeat message. fn collect_heartbeat( config: &HeartbeatConfig, @@ -758,6 +817,49 @@ mod tests { assert!(heartbeat.has_no_volumes); } + #[test] + fn test_apply_storage_backends_registers_s3_default_aliases() { + let state = test_state_with_store(Store::new(NeedleMapKind::InMemory)); + + apply_storage_backends( + &state, + &[master_pb::StorageBackend { + r#type: "s3".to_string(), + id: "default".to_string(), + properties: std::collections::HashMap::from([ + ("aws_access_key_id".to_string(), "access".to_string()), + ("aws_secret_access_key".to_string(), "secret".to_string()), + ("bucket".to_string(), "bucket-a".to_string()), + ("region".to_string(), "us-west-2".to_string()), + ("endpoint".to_string(), "http://127.0.0.1:8333".to_string()), + ("storage_class".to_string(), "STANDARD".to_string()), + ("force_path_style".to_string(), "false".to_string()), + ]), + }], + ); + + let registry = state.s3_tier_registry.read().unwrap(); + assert!(registry.get("s3.default").is_some()); + assert!(registry.get("s3").is_some()); + } + + #[test] + fn test_apply_storage_backends_ignores_unsupported_types() { + let state = test_state_with_store(Store::new(NeedleMapKind::InMemory)); + + apply_storage_backends( + &state, + &[master_pb::StorageBackend { + r#type: "rclone".to_string(), + id: "default".to_string(), + properties: std::collections::HashMap::new(), + }], + ); + + let registry = state.s3_tier_registry.read().unwrap(); + assert!(registry.names().is_empty()); + } + #[test] fn test_apply_metrics_push_settings_updates_runtime_state() { let store = Store::new(NeedleMapKind::InMemory);