Skip to content

Commit

Permalink
Merge pull request #312 from Luap99/ttl
Browse files Browse the repository at this point in the history
use lower TTL for contianer entries
  • Loading branch information
openshift-merge-robot committed Mar 31, 2023
2 parents d6001fe + f587536 commit 6c48930
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/dns/coredns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ use trust_dns_proto::{
DnsStreamHandle,
};

// Containers can be recreated with different ips quickly so
// do not let the clients cache to dns response for to long,
// aardvark-dns runs on the same host so caching is not that important.
// see https://github.com/containers/netavark/discussions/644
const CONTAINER_TTL: u32 = 60;

pub struct CoreDns {
name: Name, // name or origin
network_name: String, // raw network name
Expand Down Expand Up @@ -212,7 +218,7 @@ impl CoreDns {
if let Ok(answer) = Name::from_ascii(format!("{}.", entry)) {
req_clone.add_answer(
Record::new()
.set_ttl(86400)
.set_ttl(CONTAINER_TTL)
.set_rr_type(RecordType::PTR)
.set_dns_class(DNSClass::IN)
.set_data(Some(RData::PTR(answer)))
Expand Down Expand Up @@ -294,7 +300,7 @@ impl CoreDns {
req.add_answer(
Record::new()
.set_name(record_name.clone())
.set_ttl(86400)
.set_ttl(CONTAINER_TTL)
.set_rr_type(RecordType::A)
.set_dns_class(DNSClass::IN)
.set_data(Some(RData::A(ipv4)))
Expand All @@ -308,7 +314,7 @@ impl CoreDns {
req.add_answer(
Record::new()
.set_name(record_name.clone())
.set_ttl(86400)
.set_ttl(CONTAINER_TTL)
.set_rr_type(RecordType::AAAA)
.set_dns_class(DNSClass::IN)
.set_data(Some(RData::AAAA(ipv6)))
Expand Down

0 comments on commit 6c48930

Please sign in to comment.