Various fixes to make things less flaky:
* kubernetes: put klog.SetOutput in the setup function, not in the init
function to see if that helps
* file: make z.Expired a boolean instead of a pointer to a boolean
* test: fix TestSecondaryZoneTransfer test, which wasn't actually
testing in the right way. It's more right now, but may still be racy
(race introduced because a file's lazy loading of zones)
Signed-off-by: Miek Gieben <miek@miek.nl>
* plugin/file: simplify locking
Simplify the locking, remove the reloadMu and just piggyback on the
other lock for accessing content, which assumes things can be move
underneath.
Copy the Apex and Zone to new vars to make sure the pointer isn't
updated from under us.
The releadMu isn't need at all, the time.Ticker firing while we're
reading means we will just miss that tick and get it on the next go.
Add rrutil subpackage and put some more generic functions in there, that
are now used from file and the tree package. This removes some
duplication.
Rename additionalProcessing that didn't actually do that to
externalLookup, because that's what being done at some point.
Signed-off-by: Miek Gieben <miek@miek.nl>
* Update plugin/file/lookup.go
Co-Authored-By: Michael Grosser <development@stp-ip.net>
After calling NewZone the number of records should be zero, but due to
how zone.All() was implemented so empty RRs would be added. This then
fails the == 0 check in xfr.go and put nil in the slice, this then
subsequently panics on the Len().
Fix this making All() smarter when adding records. Added little test to
enfore this.
Signed-off-by: Miek Gieben <miek@miek.nl>
* plugin/file: make non-existent file non-fatal
If the zone file being loaded doesn't exist *and* reload is enabled,
just wait the file to pop up in the normal Reload routine.
If reload is set to 0s; we keep this a fatal error on startup. Aslo fix
the ticker in z.Reload(): remove the per second ticks and just use the
reload interval for the ticker.
Brush up the documentation a bit as well.
Fixes: #2951
Signed-off-by: Miek Gieben <miek@miek.nl>
* Stickler and test compile
Signed-off-by: Miek Gieben <miek@miek.nl>
* Remove there too
Signed-off-by: Miek Gieben <miek@miek.nl>
* Cant README test these because zone files dont exist
Signed-off-by: Miek Gieben <miek@miek.nl>
This fixes a long standing bug:
fixes: #1609
Load secondary zones in a go-routine; this required another mutex to
protect some fields; I think those were needded anyway because a
transfer can also happen when we're running; we just didn't have a test
for that situation.
The test had to be changed to wait for the transfer to happen at this is
async now.
Signed-off-by: Miek Gieben <miek@miek.nl>
* Default to upstream to self
This is a backwards incompatible change.
This is a massive (cleanup) PR where we default to resolving external
names by the coredns process itself, instead of directly forwarding them
to some upstream.
This ignores any arguments `upstream` may have had and makes it depend
on proxy/forward configuration in the Corefile. This allows resolved
upstream names to be cached and we have better healthchecking of the
upstreams. It also means there is only one way to resolve names, by
either using the proxy or forward plugin.
The proxy/forward lookup.go functions have been removed. This also
lessen the dependency on proxy, meaning deprecating proxy will become
easier. Some tests have been removed as well, or moved to the top-level
test directory as they now require a full coredns process instead of
just the plugin.
For the etcd plugin, the entire StubZone resolving is *dropped*! This
was a hacky (but working) solution to say the least. If someone cares
deeply it can be brought back (maybe)?
The pkg/upstream is now very small and almost does nothing. Also the
New() function was changed to return a pointer to upstream.Upstream. It
also returns only one parameter, so any stragglers using it will
encounter a compile error.
All documentation has been adapted. This affected the following plugins:
* etcd
* file
* auto
* secondary
* federation
* template
* route53
A followup PR will make any upstream directives with arguments an error,
right now they are ignored.
Signed-off-by: Miek Gieben <miek@miek.nl>
* Fix etcd build - probably still fails unit test
Signed-off-by: Miek Gieben <miek@miek.nl>
* Slightly smarter lookup check in upstream
Signed-off-by: Miek Gieben <miek@miek.nl>
* Compilez
Signed-off-by: Miek Gieben <miek@miek.nl>
* Configurable zone reload interval in file plugin
* passing reload config from auto plugin to file plugin. removed noReload property from Zone struct. fixed tests based on short file reload hack
* plugin/file: shutdown reload goroutine
Shutdown the z.Reload() routine (if started in the first place) on
shutdow and reload.
Fixes#1508
* Must be put in c.OnShutdown()
* up test coverage
* Rename middleware to plugin
first pass; mostly used 'sed', few spots where I manually changed
text.
This still builds a coredns binary.
* fmt error
* Rename AddMiddleware to AddPlugin
* Readd AddMiddleware to remain backwards compat