Commit graph

516 commits

Author SHA1 Message Date
Miek Gieben
50ab28aa23 mw/file: rename to BenchmarkFileLookup (#741)
In grafana we miss the context of where this is called, make the name
more descriptive.

Also test the GH webhook.
2017-06-18 19:50:38 +01:00
Chris O'Haver
7219bff11f compress empty implementations to single line (#740) 2017-06-16 09:11:53 -07:00
Miek Gieben
e49ca86ce4 cleanup: go vet and golint run (#736)
* cleanup: go vet and golint run

Various cleanups trickered by go vet and golint.

* Fix tests and lowercase all errors

Lowercase all errors, some tests in kubernetes use errors from
kubernetes which do start with a capital letter.
2017-06-14 09:37:10 -07:00
Chris O'Haver
5c10eba31c handle clusterIP endpoint queries (#730) 2017-06-14 10:29:41 -04:00
Chris O'Haver
930c54ef62 middleware/kubernetes: Implement current federation beta (#723)
* federation initial commit

* UTs/bugfixes

* federation bits

* polish, cover UT gaps

* add TODO

* go fmt & todo note

* remove unrelated change

* pr changes

* start node watcher

* get real node name

* remove unused case
2017-06-14 09:38:00 -04:00
Miek Gieben
8e86fa6f23 middleware/debug: add (#735)
* middleware/debug: add

Add a debug "middleware" that disables the recover() and just lets
CoreDNS crash; very useful for testing.

Fixes ##563

* fix test

* Feedback: check the value of Debug
2017-06-13 16:47:17 -06:00
Miek Gieben
46bf7f3106 middleware/file: consider no SOA a fatal error (#734)
Don't load a zone with a SOA record, barf with 'no SOA record' error.
2017-06-13 12:51:52 -07:00
Miek Gieben
e9eda7e7c8 New cache implementation and prefetch handing in mw/cache (#731)
* cache: add sharded cache implementation

Add Cache impl and a few tests. This cache is 256-way sharded, mainly
so each shard has it's own lock. The main cache structure is a readonly
jump plane into the right shard.

This should remove the single lock contention on the main lock and
provide more concurrent throughput - Obviously this hasn't been tested
or measured.

The key into the cache was made a uint32 (hash.fnv) and the hashing op
is not using strings.ToLower anymore remove any GC in that code path.

* here too

* Minimum shard size

* typos

* blurp

* small cleanups no defer

* typo

* Add freq based on Johns idea

* cherry-pick conflict resolv

* typo

* update from early code review from john

* add prefetch to the cache

* mw/cache: add prefetch

* remove println

* remove comment

* Fix tests

* Test prefetch in setup

* Add start of cache

* try add diff cache options

* Add hacky testcase

* not needed

* allow the use of a percentage for prefetch

If the TTL falls below xx% do a prefetch, if the record was popular.
Some other fixes and correctly prefetch only popular records.
2017-06-13 12:39:10 -07:00
Miek Gieben
f32dcf2817 Remove pkg/storage (#727)
It's not used, remove it.
2017-06-09 21:47:22 +01:00
Chris O'Haver
2ec96e0bb5 remove unused funcs (#724) 2017-06-09 08:00:09 +01:00
Pat Moroney
92dd947c51 middleware/hosts for /etc/hosts parsing (#695)
* add hosts middleware

* forgot pointer receiver

* add appropriately modified hostsfile tests from golang repo

* remove test artifacts, separate hostsfile parsing from caching and opening, remove unused metrics references, move middleware up the chain

* refactored the logic for creating records and filtering ip address versions. also got PTR lookups working

* Add README.md. Modify config to be more concise. Add zones list to config. Filter PTR responses based on zones list.

* add Fallthrough and return correct dns response code otherwise

* Simplified Hostsfile to only store hosts in the zones we care about, and by ip version. Added handler tests and improved other tests.

* oops, goimports loaded a package from a different repo
2017-06-08 20:48:04 +01:00
Miek Gieben
990460ee7c middleware/file: don't reload zone when SOA isn't changed (#707)
* middleware/file: don't reload zone when SOA isn't changed

Give Parse an extra argument which is the SOA's serial, if > 0 we check
against the just parsed SOA and then just return.

Most notable use is in reload.go which is both used in the file and auto
middleware.

Fixes #415

* PR comments
2017-06-08 18:43:11 +01:00
Miek Gieben
1c45e262f5 middleware/proxy: remove singleinflight from dns (#717)
Singleinflight interferes with the health checking of upstream. If an
upstream would fail, singleinflight would mirror that error to to other
proxy *iff* multple identical queries would be inflight. This would lead
to marking *all* upstreams as bad, essentially collapsing multiple
upstreams into a SPOF. Clearly not what we want.

Singleinflight does have some nice properties, but I've opted to rip it
out entirely. Caching should almost (but not quite) as good.

Added a test case in test that uses 3 CoreDNS instances to reflect the
setup from #715.

Found another bug as well, where (when the policy would be nil), we
would always Spray even though we've found a healthy host.
2017-06-08 16:06:14 +01:00
Miek Gieben
64640bd1a0 pkg/debug: Update comment (#704)
We already lowercase before comparing.

Fixes #447
2017-06-03 08:34:42 +01:00
Chris O'Haver
18bc52b5e0 add more coverage (#702) 2017-06-03 08:27:24 +01:00
Chris O'Haver
ecae087201 unexpose items per lint (#701) 2017-06-02 23:54:33 -04:00
Miek Gieben
bdf71cf251 middleware/proxy: silence gprc errors (#699)
* middleware/proxy: silence gprc errors

Add discard logger

* Silence glog crap

* Revert "Silence glog crap"

This reverts commit a15dafbca6.
2017-06-02 17:19:40 +01:00
Miek Gieben
7be066e4de middleware/file: add DNSSEC support (#697)
* middleware/file: add DNSSEC support

Add tests for DNSSEC and check if everything is working.

* add signatures

* tweak

* Add DNSSEC signing tests for DNAME

* Just sign it all
2017-06-02 17:18:58 +01:00
Chris O'Haver
d684dedfd3 unexpose InterfaceAddrser (#693) 2017-06-02 07:25:33 +01:00
Chris O'Haver
381ec9d7f8 fix typo (#692) 2017-06-01 22:44:10 -04:00
Miek Gieben
30ecb83dce middleware/secondary: fix crash with no zone (#680)
When CoreDNS starts up and can't get a zone transfer going the Apex is
empty. This `nil` is then transformed into wireformat, which fails with
a nil pointer dereference in Go DNS.

In this case we should just return SERVFAIL, because we don't have any
info (yet). Note the lookup code returned NXDOMAIN, which is correct
from a lookup standpoint, but also invalidates every name in the future
loaded zone.

Anyway, look for an apex before doing the lookup and return SERVFAIL if
nothing is found.

Fixes #679
2017-06-01 12:33:40 +01:00
Miek Gieben
e261ac1a6e middleware/{log,errors}: output everything to stdout (#684)
Limit the options in both errors and log middleware, just output to
stdout and let someone else (journald,docker) care about where to route
the logs. This removes syslog and logging to a file.

Fixes #573 #602
2017-05-31 20:28:53 +01:00
Jonas Östanbäck
6c774782e0 Fix typos (#682) 2017-05-30 15:03:35 +01:00
Chris O'Haver
d917ff5ac2 Add k8s external service CNAMEs (#677)
* Add external service cnames

* remove cruft

* update CI k8s version

* change CI k8s version

* min k8s ver for ext services

* trying k8s 1.5

* k8s 1.5 requires ports spec

* remove kruft

* update dns schema version
2017-05-30 13:20:39 +01:00
cricketliu
2f2c90f391 Update README.md (#668)
* Update README.md

Minor cosmetic fixes, including one broken comment in a sample Corefile.

* Fix verb tense
2017-05-26 09:02:51 -04:00
Eric Yan
d2268d3030 middleware/file: add DNAME support (#651)
* Test DNAME handling

If the DNAME itself matches the QTYPE, and the owner name matches QNAME,
the relevant DNAME RR should be included in the answer section.

Other parts of RFC 6672 are not implemented yet and hence left untested.

* Implement the DNAME substitution

As specified in RFC 6672, a DNAME substitution is performed by replacing
the suffix labels of the name being sought matching the owner name of
the DNAME resource record with the string of labels in the RDATA field.
The matching labels end with the root label in all cases. Only whole
labels are replaced.

* Handle DNAME redirection

A CNAME RR is created on-the-fly for the DNAME redirection. Be aware
that we do not have all the edge cases covered yet.

* Test DNAME owner name matching the QNAME

A DNAME RR redirects DNS names subordinate to its owner name; the owner
name of a DNAME is NOT redirected itself.

* Ignore names next to and below a DNAME record

According to RFC 6672, resource records MUST NOT exist at any subdomain
of the owner of a DNAME RR. When loading a zone, those names below the
DNAME RR will be quietly ignored.

* Streamline DNAME processing

Instead of checking DNAMEs during lookup, we use a preloaded list of
DNAME RRs to streamline the process without any runtime performance
penalty:

 * When loading the zone, keep a record of any DNAME RRs.
 * If there aren't any DNAMEs in the zone, just do the lookup as usual.
 * Only when the zone has one or more DNAME records, we look for the
   matching DNAME and ignore confronting subdomain(s) in the process.

* Make it easier to trace back through test errors

* Make DNAME handling part of lookup routine

DNAME processing is invoked only if the zone has at least one DNAME RR.

* Put DNAME resolution inside the searching of a hit

We can drop some of the other ideas; we don't need to track if we
have DNAMEs in the zone it just follows naturally from the current
lookup code.

See also: #664
2017-05-26 10:37:06 +01:00
Manuel Alejandro de Brito Fontes
7c8d1b0234 Check that all the controllers are synced agains api server (#671) 2017-05-25 20:08:44 +01:00
Yong Tang
37050dc217 Some golint cleanup (#674)
This commit fixes some golint issues in `core/dnsserver`
and `middleware/kubernetes`.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-05-25 20:08:34 +01:00
Chris O'Haver
7f950e496a Handle K8s middleware NS record (#662)
* commit for testing in cluster

* commit for testing in cluster

* refactor and add ns.dns record

* Release 007

* reduce heap allocations

* gofmt

* revert accidental Makefile commits

* restore prior rcode for disabled pod mode

* revert Makefile deltas

* add unit tests

* more unit tests

* make isRequestInReverseRange easier to test

* more unit tests

* addressing review feedback

* commit setup.go
2017-05-22 16:05:48 -04:00
Miek Gieben
024f56682d middleware/chaos: fix version (#669)
* middleware/chaos: fix version

Move the version setting into a init function so it is done early. Then
tweak the setup code for chaos a bit to correctly pick this version up.
Add an integration test to pick this up in the toplevel test/ directory.

Fixes #667

* Update tests
2017-05-22 08:09:35 -04:00
Miek Gieben
8eda6c7b9c middleware/file: correctly parse the stanza (#658)
* middleware/file: correctly parse the stanza

Parsing the file stanza would give precedence to 'transfer' and ignore
other bits if it wasn't specified.

This change fixes the parsing. The actually external CNAME retrieval is
working fine (once the upstream is correctly parsed).

This wasn't caught in tests, because we lack a parsing test for this.

Fixes #657

* Add tests
2017-05-03 16:36:41 +01:00
John Belamaric
6062e58c59 Remove annoying INFO from k8s middleware (#655) 2017-04-30 08:48:37 +01:00
Miek Gieben
7d39c2ba51 middleware/cache: don't cache expired RRSIGs (#641)
Check message for expired sig and don't cache those.

Aside: This hack of caching entire messages is probably something we
should stop doing at some point in the future and do this on a per RRset
basis.

Fixes #367 #635
2017-04-29 07:06:42 -07:00
Miek Gieben
3b5b6a233f middleware/proxy: Kill goroutines on stop (#646)
* middleware/proxy: Kill goroutines on stop

Ports caddy's 59bf71c293

Excludes the proxy_test.go test part though.

Fixes #644

* Add tests
2017-04-26 10:58:14 +01:00
Miek Gieben
003b1bf678 Fix health race (#645)
* Revert "middleware/proxy: Make Unhealthy a pointer (#615)"

This reverts commit acbf522ceb.

* middleware/proxy: add proper locking

This add the proper locking around `Unhealthy`.
2017-04-24 20:37:43 +01:00
Chris O'Haver
f359aea2fa Pprof listen (#639)
* add listen addr option

* Add listen address option to pprof

* There is configuration

* code styling
2017-04-24 10:27:26 -04:00
Miek Gieben
4c9351b0a3 msg.Service: add HostType() method (#627)
This method parses the Host field in the service. It returns 1 or 3
things 1) it is a host 2) an IPv4 address or an 3) IPv6 address.
This simplifies some code a bit and allows for 1 way of parsing the Host
field.

This *only* parse the Host field, Mail and/or Text values should be
checked separately.

We reuse the dns.TypeXXX values for this as to not invent anything new.
2017-04-22 07:58:30 +01:00
Chris O'Haver
320cf97868 Fix go pprof lib link (#638) 2017-04-21 14:17:50 -04:00
Dominic
e9f6a1b4ce Fix link to SkyDNS (#637)
Url was wrong
2017-04-21 10:21:56 +01:00
Yue Ko
387d3f5a41 Fix TLS error message (#634)
Print corresponding error message when TLS initialization fails.
2017-04-20 09:40:18 -04:00
John Belamaric
e5b2cbb701 Clean up the tls middleware README (#631) 2017-04-19 22:43:10 +01:00
John Belamaric
8fc7ec776d Update the various Kubernetes middleware README files. (#630) 2017-04-19 22:42:45 +01:00
John Belamaric
1c53d4130e Add fallthrough support for Kubernetes (#626)
* Add fallthrough support for Kubernetes

This enables registering other services in the same zone as
Kubernetes services. This also re-orders the middleware chain
so that Kubernetes comes before other types, in order to make
this work out-of-the-box.

* Remove extra line
2017-04-19 16:08:30 -04:00
John Belamaric
5a60090933 Tracing for gRPC Server (#619)
* Implements tracing in the native gRPC server

* Undo some unnecessary changes

* Properly revert trace/setup.go this time

* Some very very basic tests

* Remove warning for non-Trace middleware
2017-04-18 11:10:49 -04:00
Miek Gieben
73397e4667 Tc bits (#617)
* middleware/erratic: allow TC bit to be set

Add `truncate` as an option.

Fixes #593
2017-04-16 07:49:13 +01:00
Miek Gieben
a83d97a5c4 middleware/erratic: add delaying queries (#614)
* middleware/erratic: add delying queries

* Dont println
2017-04-13 16:26:17 +01:00
Miek Gieben
acbf522ceb middleware/proxy: Make Unhealthy a pointer (#615)
Pointer updates are atomic so drop the sync.RWMutex as it is not needed
anymore. This also fixes the race introduced with dfc71df (although I
believe this is the first time we properly tested that code path).
2017-04-13 16:26:05 +01:00
Miek Gieben
c262946009 middleware/metrics: allow multiple listeners
There was no inherent reason *not* to allow multiple listeners for the
monitoring data. Actually enforcing only one listener lead to more code
then just allowing multiple. It's probably not what you want; but
CoreDNS is happy to oblige.
2017-04-12 10:10:57 +00:00
Miek Gieben
72f5a92d30 Random fixes (#605) 2017-03-18 17:08:39 +00:00
Michael S. Fischer
7dc431ada3 middleware/proxy: fix race; add Go 1.7 backward compatibility (#603)
* Fix race on backend health status update
* Ensure test case is compatible on Go 1.7
2017-03-17 07:20:55 +00:00