v0.35.2
This commit is contained in:
1 parent
09414dfb09
commit
f4606cce18
36 files changed
+641
-74
No files matched your search
@@ -104,8 +104,23 @@ pub(crate) fn compile_backend_with_timeout(
|
||||
targets_admin_listener,
|
||||
client,
|
||||
websocket_client,
|
||||
health_probe: None,
|
||||
})
|
||||
}
|
||||
|
||||
/// Backend copy used only by active health checks that probe a different port.
|
||||
pub(crate) fn health_probe_backend(backend: &Backend, port: Option<u16>) -> Result<Option<Backend>> {
|
||||
let Some(port) = port else { return Ok(None) };
|
||||
let mut url = Url::parse(&backend.url).context("invalid backend URL")?;
|
||||
if url.port_or_known_default() == Some(port) {
|
||||
return Ok(None);
|
||||
}
|
||||
url.set_port(Some(port))
|
||||
.map_err(|_| anyhow::anyhow!("backend URL does not accept a health check port"))?;
|
||||
let mut probe = backend.clone();
|
||||
probe.url = url.as_str().trim_end_matches('/').to_owned() + "/";
|
||||
Ok(Some(probe))
|
||||
}
|
||||
pub fn compile(config: Config, revision: u64, policy: &ValidationPolicy) -> Result<Snapshot> {
|
||||
compile_with_defaults(
|
||||
config,
|
||||
|
||||
@@ -224,6 +224,7 @@ pub struct CompiledBackend {
|
||||
pub tls_verify: bool,
|
||||
pub accept_local_listener_risk: bool,
|
||||
pub targets_admin_listener: bool,
|
||||
pub health_probe: Option<Arc<CompiledBackend>>,
|
||||
}
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum CompiledSource {
|
||||
|
||||
+24
-3
@@ -99,17 +99,38 @@ fn compile_routing(
|
||||
});
|
||||
let mut compiled_members = Vec::new();
|
||||
for definition in host.backends.iter().filter(|_| needs_proxy_pool) {
|
||||
let connect_timeout = host
|
||||
.proxy_timeouts
|
||||
.connect_timeout()
|
||||
.unwrap_or(std::time::Duration::from_secs(10));
|
||||
let mut backend = compile_backend_with_timeout(
|
||||
&definition.backend(),
|
||||
desired_policy,
|
||||
guarded_bindings,
|
||||
&host.load_balancing.keepalive,
|
||||
host.proxy_timeouts
|
||||
.connect_timeout()
|
||||
.unwrap_or(std::time::Duration::from_secs(10)),
|
||||
connect_timeout,
|
||||
)
|
||||
.with_context(|| format!("vhost {} backend {}", host.id, definition.id))?;
|
||||
backend.id = format!("{}/{}", host.id, definition.id);
|
||||
let health = host.load_balancing.health_for(definition);
|
||||
if health.mode != crate::balance::HealthMode::Off {
|
||||
if let Some(probe) =
|
||||
health_probe_backend(&definition.backend(), health.port)?
|
||||
{
|
||||
let mut probe = compile_backend_with_timeout(
|
||||
&probe,
|
||||
desired_policy,
|
||||
guarded_bindings,
|
||||
&host.load_balancing.keepalive,
|
||||
connect_timeout,
|
||||
)
|
||||
.with_context(|| {
|
||||
format!("vhost {} backend {} health check port", host.id, definition.id)
|
||||
})?;
|
||||
probe.id = format!("{}/{}#health", host.id, definition.id);
|
||||
backend.health_probe = Some(Arc::new(probe));
|
||||
}
|
||||
}
|
||||
compiled_members.push(Arc::new(backend));
|
||||
}
|
||||
let pool = if compiled_members.is_empty() {
|
||||
|
||||
Reference in new issue
Block a user