Commit graph

3613 commits

Author SHA1 Message Date
Miek Gieben
2cca527d9f middleware/file: fix delegations (#376)
Fix the delegation handling in the *file* and *dnssec* middleware.
Refactor tests a bit and show that they are failling.

Add a Tree printer, cleanups and tests.
Fix wildcard test - should get no answer from empty-non-terminal
2016-11-05 14:39:49 +00:00
Miek Gieben
d6902cd7a1 Disable metrics test (#380)
Disable this test (for now), it fails weirdly on travis
(and not locally). Initial suspicion that another server
is still reporting (or something). Anyway hard to replicate
locally - disable it for now.
2016-11-05 14:38:49 +00:00
John Belamaric
229c82c418 Fix k8s client (#379)
* Fix k8s client to use client-go

* Fix Kubernetes Build Issue

The client-go code requires you to vendor. I have done a hack here
in the Makefile to vendor it to version 1.5. But looks like we
will need to do this the 'right' way soon.

* Convert v1 to api Objects in List Functions

Also removed the endpoint controller which was not used for anything.
The Watch functions may still need the same treatment.

* Vendor client-go release-1.5

* Fix basic SRV feature

This is actually not serving SRV records correctly, but this should
get it to work as it did prior to the k8s client changes. Another
fix will be needed to serve SRV records as defined in the spec.

* Add additional output in test result

Add the response to the test output.

* Fix erroneous test data
2016-11-05 11:57:08 +00:00
Ben Kochie
775d26c5e2 Add metrics for cache hits/misses (#375)
* Add metrics for cache hits/misses

Add counters for cache middleware hits and misses.

* Add test for cache middleware hit/miss counters.

* Fix cache hit metric incrementing.

* Add cache hit/miss metrics to dnssec middleware.

* Update README metric documentation.
2016-10-31 18:50:50 +00:00
Miek Gieben
27d893cf33 ServiceBackend interface (#369)
* Add ServiceBackend interface

This adds a ServiceBackend interface that is shared between etcd/etcd3
(later) and kubernetes, leading to a massive reduction in code. When
returning the specific records from their backend.

Fixes #273
2016-10-30 15:54:16 +00:00
Miek Gieben
81d5baee28 middleware/cache: fix metrics test
Fix the metrics test, top-level test directory still referenced the
old metrics name.
2016-10-30 15:08:40 +00:00
Manuel Alejandro de Brito Fontes
1b923adde6 Fix k8s build (#373) 2016-10-30 14:58:33 +00:00
Ben Kochie
98a8fb2622 Update metric names (#371)
Cleanup names/typos to match standard naming conventions.
2016-10-30 09:06:57 +00:00
Miek Gieben
490ffbd6d2 go vet issue 2016-10-28 12:59:18 +01:00
Miek Gieben
cb867ff6bd middleware/metrics: export ListenAddr (#366)
ListenAddr is the address where the prometheus metric are exported.
This can be used in tests to listen on "localhost:0" and then later
retrieve the metrics from there. It makes the tests indepent on each
other.
2016-10-28 12:57:10 +01:00
Miek Gieben
0509f4b4ac middleware/file: reload on file mv (#365)
When a file is moved into position we should also reload the zones'
content.

This also fixes deadlock bug in the locking, a reload would block any
further lookups.
2016-10-28 12:57:02 +01:00
Miek Gieben
54964653d1 middleware/proxy: add request duration monitoring (#362)
Add a separate request duration metrics specially for proxying requests
upstream.

Fixes #259
2016-10-28 12:54:49 +01:00
Miek Gieben
ba26f47d5c middleware/caching (#360)
Add the rcode to the cached item and use this when we synthesize the
answer again. We could also infer the rcode from the reassembled
message, but this seems easier and is only an integer.

Also set the autoritative bit to 0 for all from-cache answers.

Fixes 357
2016-10-28 07:50:16 +01:00
Miek Gieben
039596f319 middleware/file: add test for reload (#361)
This add a highlevel integration test for zone reloading. It also
fixes a data race in the actual reloading process.
2016-10-27 21:01:04 +01:00
Miek Gieben
94dc28646d golint 2016-10-27 11:48:37 +00:00
Jonathan Dickinson
7ce7100122 - Adding tests for MX round-robin (#358)
- Implementing MX round-robin
- Slight tidy
2016-10-27 08:09:16 +01:00
Miek Gieben
219bfd0493 middleware/metrics: cleanup (#355)
* middleware/metrics: add more metrics

middleware/cache:
Add metrics for number of elements in the cache. Also export the total
size. Update README to detail the new metrics.

middleware/metrics

Move metrics into subpackage called "vars". This breaks the import
cycle and is cleaner. This allows vars.Report to be used in the
the dnsserver to log refused queries.

middleware/metrics: tests

Add tests to the metrics framework. The metrics/test subpackage allows
scraping of the local server. Do a few test scrape of the metrics that
are defined in the metrics middleware.

This also allows metrics integration tests to check if the caching and
dnssec middleware export their metrics correctly.

* update README

* typos

* fix tests
2016-10-26 10:01:52 +01:00
John Belamaric
6d9d60081d Add option to parse resolv.conf for proxy upstreams (#353)
* Add option to parse resolv.conf for proxy upstreams

* Add test and README update for resolv.conf proxy

* Run gofmt
2016-10-22 15:52:10 +01:00
Yong Tang
a2bd9ad3f5 Use docker container (instead of binary) for kubectl and travis cleanup (#352)
This fix uses docker container for kubectl. Since Kubernetes docker
image hyperkube has already been downloaded and it consists of
kubectl, there is really no need to download kubectl binary again.

This fix cleans up the Kubernetes related travis setup and removes
unneeded scripts.

This fix also fixes several mismatches of the Kubernetes version used,
so that any changes in version in the future only need to update .travis.yml.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-10-20 11:06:15 -07:00
John Belamaric
14dc376ee7 Enable use of a service account in-cluster. (#349) 2016-10-19 22:04:35 +01:00
Miek Gieben
9a048663cf Release 002 2016-10-19 20:49:27 +01:00
Miek Gieben
2e68682d4d releasing 002 2016-10-19 20:34:28 +01:00
Miek Gieben
4f36e63a05 middleware/file: fix DS handling (#344)
The DS record is handled specially in the server ServeDNS mux, but there
was no code that actually called the correct middleware handler chain
when encountering a DS.

This PR fixes that behavoir, additonal bugs has been files to look into
how we are handling delegation (secure and non-secure ones).
2016-10-19 17:46:03 +01:00
Yong Tang
ad7e78ec31 Add cache_capacity option to dnssec middleware for the capacity of LRU cache (#339)
This fix adds a `cache_capacity` option to dnssec middleware, so that
it is possible to specify the capacity of the LRU cache used by dnssec
middleware.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-10-18 13:33:23 -07:00
Miek Gieben
4d55f90388 middleware/etcd: more tests (#342)
Add a test which enables caching and debug queries and make sure
the debug query does not overwrite the cache.
2016-10-18 12:05:19 +01:00
Miek Gieben
89a2912c87 Documentation updates (#340) 2016-10-18 07:47:18 +01:00
Miek Gieben
a6b033a936 We dont support log rotation anymore 2016-10-18 07:03:51 +01:00
Yong Tang
7843a2bd91 Small golint cleanup. (#338)
A small golint cleanup.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-10-17 16:59:12 -07:00
Miek Gieben
d536272201 middleware/auto: add (#333)
Add auto-load middleware that automatically picks up zones.

Every X seconds it will scan for new zones.
Add tests and documentation.

Make 'make test' use -race.
2016-10-17 18:37:56 +01:00
Zhipeng JIANG
2eafe3ee94 Fix files reload failure within a single root zone. (#337)
In the file middleware, if there are multiple zone files under a single root zone, watchers are only invoked on the last element of `zones.Names`. This is caused by loop override on the variable `n`.

This issue can be fixed by passing zone object, which calls reload watcher directly.
2016-10-17 17:04:18 +01:00
Yong Tang
58387afd5d Replace go-cache with golang-lru in dnssec (#336)
* Replace go-cache with golang-lru

This fix replace go-cache with golang-lru, as is specified in 335.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Move cache initialization to setup

This commit move cache initialization to setup in dnssec middleware.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-10-17 13:04:36 +01:00
Miek Gieben
03bc071774 Check for empty message in typify 2016-10-17 10:26:24 +00:00
Miek Gieben
be3c0195b6 middleware.md: put in the same doc
Move middleware/middleware.md to middleware.md. This should be the
canonical place where to document how middlewares should look and act.
2016-10-17 07:51:44 +01:00
Yong Tang
a69e88db62 Add needed comments for golint cleanup. (#334)
This fix adds several needed comments in
`middleware/kubernetes/nametemplate/nametemplate.go`
to clean up golint output.

There are still 3 places that needs proper docs:
```
middleware/kubernetes/nametemplate/nametemplate.go:64:1: comment on exported type Template should be of the form "Template ..." (with optional leading article)
middleware/kubernetes/nametemplate/nametemplate.go:72:1: comment on exported method Template.SetTemplate should be of the form "SetTemplate ..."
middleware/kubernetes/nametemplate/nametemplate.go:188:1: comment on exported type NameValues should be of the form "NameValues ..." (with optional leading article)
```

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-10-14 16:28:15 -07:00
Miek Gieben
aa7744dc86 cleanups: go vet/golint (#331)
Go vet and golint the new code once again.

Drop Name from NameTemplate - it's cleaner: nametemplate.Template.
2016-10-12 12:46:35 +01:00
Miek Gieben
710c9b111f middleware/root: add it (#330)
This PR adds the *root* middleware that specifies a path where
all zone file (the *file* middleware is the only consumer now) can
be found. It works the same as in Caddy.

Documentation can be found in the README.md of the middleware.

Fixes #307
2016-10-11 20:42:28 +01:00
Yong Tang
baea5eef2f Add a unit test for DuplicateCNAME (#329)
This fix adds a unit test for DuplicateCNAME to have
a basic coverage for dnsutil.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-10-11 20:25:50 +01:00
Yong Tang
f3066b9463 Add unit tests for ExtractAddressFromReverse (#328)
This fix adds unit tests for `ExtractAddressFromReverse`. It also
updates the implementation of `ExtractAddressFromReverse` so that
only a valid IPv4 or IPv6 address (in string format) is returned.

If the addresses is not valid and can not be handled by golang's
`net.ParseIP` then an empty string (`""`) will be returned.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-10-11 09:48:15 +01:00
Miek Gieben
faf83b00dd docs: rewrite using manpage style (#327)
This still needs cleanup, but this is a first pass the cleans some
cruft and documents our style (in middleware.md) and makes all the
docs match that style.
2016-10-10 20:13:22 +01:00
Miek Gieben
c22b7b2252 middleware/log: allows logging based on response classes (#325)
Add the ability to add a class of responses to be logged; success,
denial or error. The default is to log everything (all).

Fixes #258
2016-10-10 12:09:29 +01:00
Miek Gieben
caa3976bfe middlewate/etc: fix test here as well
Make tests compile; failed to catch this due to use of tags for this
part of the (test) code.
2016-10-08 18:19:42 +01:00
Miek Gieben
99cd11c2d4 Add secondary test 2016-10-08 18:06:28 +01:00
Miek Gieben
e8b4412564 tests: clean up output
Some document improvements and add a few more tests.
2016-10-08 16:44:43 +01:00
Miek Gieben
e43384b501 middleware/file: proper support for wildcard (#323)
Add support for wildcard records, while taking care of wildcard-cnames
and DNSSEC. Add enough tests to check all the corner cases.
2016-10-08 15:22:31 +01:00
Miek Gieben
b44d82839f middleware/cache: rename categories (#321)
Rename: positive -> success
negative -> denial

There is a third (unused category) which is error. Start using these
new in the caching middleware and later in the logging middleware.
2016-10-08 15:12:28 +01:00
Miek Gieben
6cf14746ad small fix 2016-10-08 15:07:07 +01:00
Miek Gieben
a05901f62a middleware/proxy: make it scale (#287)
* middleware/proxy

Use connection pooling for communicating with an upstream, instead of
opening a new socket every time.

This makes the proxy more efficient and allowed for some cleanups.

* Some cleanups

* Some fixes

* more

* Kill pool

* Add nil check

* remove pool
2016-10-08 14:46:22 +01:00
Miek Gieben
f29f622ec7 Use dns.port argument as default
Make DefaultPort just be 53. And use the value of Port to make the zone
stanzas complete (instead of defaulting to 53 always). This allows you
to override the port with dns.port.
2016-10-07 10:16:28 +00:00
Miek Gieben
ea98429512 kubernetes: hide contrib (#320)
This is purely travis (and maybe local testing). Does not warrent (IMHO)
a contrib/ directory. Hide it in a .travis directory.
2016-10-05 16:17:52 +01:00
Miek Gieben
db6c9a3f01 middleware/metrics: fix crash on startup (#318)
Make the methods that handle Metrics all use pointer receivers to fix
sync.Once not being initialized.

Finish the setup_test to test for failures. And make the check for the
address more strict and return an error when it does not have a port
number.

Add a toplevel test that starts a CoreDNS server with metrics enabled
so we catch these errors in the future.
2016-10-04 11:05:04 +01:00