fix(local-online-config): wrong Server source of OnlineConfig loader

FATAL: This will cause PingBalancer adds OnlineConfig servers every
update_intervals and never replaces them, which will eventually cause OOM.
This commit is contained in:
zonyitoo
2024-06-19 23:49:32 +08:00
parent 254da692ad
commit fdcff18e6f
2 changed files with 17 additions and 2 deletions
+7 -2
View File
@@ -1864,6 +1864,11 @@ impl Config {
}
}
let server_source = match config_type {
ConfigType::Local | ConfigType::Server | ConfigType::Manager => ServerSource::Configuration,
ConfigType::OnlineConfig => ServerSource::OnlineConfig,
};
// Standard config
// Server
match (config.server, config.server_port, config.password, &config.method) {
@@ -1906,7 +1911,7 @@ impl Config {
};
let mut nsvr = ServerConfig::new(addr, password, method);
nsvr.set_source(ServerSource::Configuration);
nsvr.set_source(server_source);
nsvr.set_mode(global_mode);
if let Some(ref p) = config.plugin {
@@ -2026,7 +2031,7 @@ impl Config {
};
let mut nsvr = ServerConfig::new(addr, password, method);
nsvr.set_source(ServerSource::Configuration);
nsvr.set_source(server_source);
// Extensible Identity Header, Users
if let Some(users) = svr.users {
@@ -741,6 +741,14 @@ impl PingBalancer {
}
}
trace!(
"ping balancer going to replace {} servers (total: {}) with {} servers, sources: {:?}",
old_context.servers.len() - old_servers.len(),
old_context.servers.len(),
servers.len(),
replace_server_sources
);
let mut servers = servers
.into_iter()
.map(|s| {
@@ -763,6 +771,8 @@ impl PingBalancer {
)));
}
trace!("ping balancer merged {} new servers", servers.len());
let (shared_context, task_abortable) = PingBalancerContext::new(
servers,
old_context.context.clone(),