Skip to content

Commit e272ca0

Browse files
committed
introduce tenant dns caching for CNAMES only
1 parent 02df8e3 commit e272ca0

File tree

4 files changed

+127
-187
lines changed

4 files changed

+127
-187
lines changed

src/balancerd/src/bin/balancerd.rs

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,10 @@ use std::path::PathBuf;
1818
use std::time::Duration;
1919

2020
use anyhow::Context;
21-
use hickory_resolver::{
22-
Resolver, config::*, name_server::TokioConnectionProvider, system_conf::read_system_conf,
23-
};
2421
use jsonwebtoken::DecodingKey;
2522
use mz_balancerd::{
2623
BUILD_INFO, BalancerConfig, BalancerResolver, BalancerService, CancellationResolver,
27-
FronteggResolver, SniResolver, create_default_resolver,
24+
FronteggResolver, SniResolver,
2825
};
2926
use mz_frontegg_auth::{
3027
Authenticator, AuthenticatorConfig, DEFAULT_REFRESH_DROP_FACTOR,
@@ -245,7 +242,7 @@ pub async fn run(args: ServiceArgs, tracing_handle: TracingHandle) -> Result<(),
245242

246243
(
247244
BalancerResolver::MultiTenant(
248-
create_default_resolver(),
245+
mz_balancerd::TenantDnsResolver::new(),
249246
FronteggResolver {
250247
auth,
251248
addr_template,
@@ -283,35 +280,8 @@ pub async fn run(args: ServiceArgs, tracing_handle: TracingHandle) -> Result<(),
283280
};
284281
drop(addrs);
285282

286-
// Create a resolver for static addresses with the same caching configuration
287-
let mut resolver_opts = ResolverOpts::default();
288-
resolver_opts.cache_size = 10000;
289-
resolver_opts.positive_max_ttl = Some(Duration::from_secs(10));
290-
resolver_opts.positive_min_ttl = Some(Duration::from_secs(9));
291-
resolver_opts.negative_min_ttl = Some(Duration::from_secs(1));
292-
293-
// Read system DNS configuration or fall back to defaults
294-
let (config, opts) = read_system_conf()
295-
.map(|(config, mut opts)| {
296-
// Override specific options while keeping system DNS servers
297-
opts.cache_size = resolver_opts.cache_size;
298-
opts.positive_max_ttl = resolver_opts.positive_max_ttl;
299-
opts.positive_min_ttl = resolver_opts.positive_min_ttl;
300-
opts.negative_min_ttl = resolver_opts.negative_min_ttl;
301-
(config, opts)
302-
})
303-
.unwrap_or_else(|err| {
304-
eprintln!("Failed to read system DNS configuration for static resolver, using defaults: {}", err);
305-
(ResolverConfig::default(), resolver_opts)
306-
});
307-
308283
(
309-
BalancerResolver::Static(
310-
Resolver::builder_with_config(config, TokioConnectionProvider::default())
311-
.with_options(opts)
312-
.build(),
313-
addr.clone(),
314-
),
284+
BalancerResolver::Static(addr.clone()),
315285
CancellationResolver::Static(addr),
316286
)
317287
}

0 commit comments

Comments
 (0)