Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make the minimum cache TTL configurable (CACHE_MIN_TTL)
Summary
Unbound and encrypted-dns both cache answers for at least one hour
(
cache-min-ttl: 3600andcache_ttl_min = 3600), even when a record's TTL isshorter. That's a good default for a busy public resolver, but it means record
changes can take an hour or more to reach clients, which is noticeable on
smaller servers.
This adds an optional
CACHE_MIN_TTLenvironment variable, in seconds from 0 to86400, that sets the minimum for both caches. Without it, the one-hour default
is kept, so existing deployments behave exactly as before.
Usage
CACHE_MIN_TTL=0honors the TTLs set by the zone owners.Changes
entrypoint.sh:start()validatesCACHE_MIN_TTLand refuses to start witha clear error if it isn't a number from 0 to 86400. Leading zeros are stripped,
since TOML doesn't allow them. The value (or 3600 when unset) is written to
cache_ttl_minin the encrypted-dns config in the keys volume, only when itdiffers from what's already there. It's passed to Unbound through
/etc/cache-min-ttl-env, the same wayOPENNICis, since runit clears theenvironment before starting services.
unbound.sh:cache-min-ttlis filled in fromCACHE_MIN_TTL, defaulting to3600.
README.md: new "Cache TTL" section.Testing
bash -nandshellcheckon both scripts: no new findings.0,60,0060,86400) andrejected ones (
86401,abc,-5,1e3, a 21-digit number).unbound.confandencrypted-dns.tomlwith the variable set to 60, unset, and invalid.OPENNIC=1andCACHE_MIN_TTL=0: the generatedunbound.confhascache-min-ttl: 0, the encrypted-dns config hascache_ttl_min = 0, and all services run normally.