Commit graph

487 commits

Author SHA1 Message Date
Miek Gieben
300506ee91
plugin/log: detail {combined} and {common} (#2422)
These can be used (and are handy), document them.

Signed-off-by: Miek Gieben <miek@miek.nl>
2019-01-04 19:39:02 +00:00
Isolus
7642995558 disable ra flag for several plugins (#2408)
* disable ra flag for several plugins

* removed unnecessary assignment

* removed more unnecessary assignments
2018-12-30 17:05:08 +01:00
Miek Gieben
14f8b5d75a
Fuzzing: add more fuzzing targets (#2402)
* Add more fuzzing

Signed-off-by: Miek Gieben <miek@miek.nl>

* More fuzzing targets

Signed-off-by: Miek Gieben <miek@miek.nl>

* Fuzzing: add more fuzzing targets

Also add Corefile fuzzing.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-17 07:49:15 +00:00
Miek Gieben
775cf92f03 plugin/loop: show from -> to (#2400)
Show from and to address when detecting a loop they may aid in
debugging.

Hard to create a unit test, but this is a startup run with self induced
loop:

~~~ corefile
.:1053 {
    loop
    log
    forward . 127.0.0.1:1053
}
~~~~

~~~
:1053
2018-12-16T10:11:03.695Z [INFO] CoreDNS-1.3.0
2018-12-16T10:11:03.695Z [INFO] linux/amd64, go1.11,
CoreDNS-1.3.0
linux/amd64, go1.11,
2018-12-16T10:11:03.696Z [FATAL] plugin/loop: Loop (127.0.0.1:51384 -> :1053) detected for zone ".", see https://coredns.io/plugins/loop#troubleshooting. Query: "HINFO 2781022615773629442.4133547885299871809."
~~~

Update the docs and polished that a bit as well.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-16 13:48:09 -08:00
Miek Gieben
c1c98924c3
Add new plugin: external - resolve k8s ingress and LB address with external names (#2379)
* Add new plugin: external

This plugin works in conjunction with the kubernetes plugin and exports
ingress and LB addresses as DNS records. It bypasses backend.go and
backend_lookup.go flow because it is not needed.

README, tests are implemented. The tests only exercise the unit tests,
this has not been tested in any ci.

Signed-off-by: Miek Gieben <miek@miek.nl>

* Rename to k8s_external

Signed-off-by: Miek Gieben <miek@miek.nl>

* go gen

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-14 09:41:51 +00:00
Miek Gieben
d0adf6f3a6
edns0 compliance: set correct RCODE (#2388)
The miekg/dns API is a bit scruffy (documentation PR in flight soon),
but these both need to be set for the correct RCODE to be reflected in
the returned packet.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-11 20:27:29 +00:00
Miek Gieben
9abbf4a4a0 map bool -> map struct{} (#2386)
This clear out the remaining map[x]bool usage and moves the bool to an
empty struct.

Two note worthy other changes:

* EnableChaos in the server is now also exported to make it show up in
  the documentation.
* The auto plugin is left as is, because there the boolean is
  explicitaly set to false to signal 'to-be-deleted' and the key is left
  as-is.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-10 02:17:15 -08:00
Yong Tang
c788649a00 Replace bool map with struct{} map in chaos plugin (#2384)
Automatically submitted.
2018-12-08 23:57:57 +00:00
Miek Gieben
95546dfdfe plugin/kubernetes: smaller map (#2383)
* plugin/kubernetes: smaller map

to continue with a theme: the map[string]bool can be reduced
to map[string]struct{} to reduce a tiny amount of memory.

Signed-off-by: Miek Gieben <miek@miek.nl>

* fix tests

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-08 15:40:07 -08:00
Yong Tang
0f7d95b1e7
Convert bool map to struct{} map in etcd.go (#2381)
This fix converts bool map to struct{} map in etcd.go
(there might be several other places).

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2018-12-08 06:15:11 -08:00
Miek Gieben
f02da83e9c plugin/kubernetes: make prefix key in msg.Service a const (#2378)
This is a relic from the etcd integration and only used to remove in the
final answer returned to the client. We do need it. Make it a constant
and only one character wide.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-08 05:37:00 -08:00
Miek Gieben
65be561722 Make backand.go maps smaller (#2380)
These maps where all map[x]bool. Change this a map[x]struct{} as this
is smaller and we only use these map to signal "this element exists".

This should preserve a (small) amount of memory.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-08 05:19:22 -08:00
Miek Gieben
8a5eb58bc0 msg.Service: optimize a bit (#2374)
Make the NewSRV and friends slightly smarter. Optimize the calling of
targetStrip which is almost certainly not used.

Added benchmark show a modest improvement:

benchmark             old ns/op     new ns/op     delta
BenchmarkNewSRV-4     300           283           -5.67%

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-07 12:09:09 -08:00
StormXX
16197a1add fix a document error (#2376) 2018-12-07 09:45:13 +00:00
Daniel Garcia
4a3f5cc41e Use Trim(Prefix/Suffix) instead of Trim(Left/Right) in rewrite prefix plugin (#2364) (#2372) 2018-12-06 22:10:46 +00:00
Miek Gieben
fc667b98e0
Fix EDNS0 compliance (#2357)
* Fix EDNS0 compliance

Do SizeAndDo in the server (ScrubWriter) and remove all uses of this
from the plugins. Also *always* do it. This is to get into compliance
for https://dnsflagday.net/.

The pkg/edns0 now exports the EDNS0 options we understand; this is
exported to allow plugins add things there. The *rewrite* plugin used
this to add custom EDNS0 option codes that the server needs to
understand.

This also needs a new release of miekg/dns because it triggered a
race-condition that was basicly there forever.

See:
* https://github.com/miekg/dns/issues/857
* https://github.com/miekg/dns/pull/859

Running a test instance and pointing the https://ednscomp.isc.org/ednscomp
to it shows the tests are now fixed:

~~~
EDNS Compliance Tester
Checking: 'miek.nl' as at 2018-12-01T17:53:15Z

miek.nl. @147.75.204.203 (drone.coredns.io.): dns=ok edns=ok edns1=ok edns@512=ok ednsopt=ok edns1opt=ok do=ok ednsflags=ok docookie=ok edns512tcp=ok optlist=ok
miek.nl. @2604:1380:2002:a000::1 (drone.coredns.io.): dns=ok edns=ok edns1=ok edns@512=ok ednsopt=ok edns1opt=ok do=ok ednsflags=ok docookie=ok edns512tcp=ok optlist=ok

All Ok
Codes
ok - test passed.
~~~

Signed-off-by: Miek Gieben <miek@miek.nl>

Signed-off-by: Miek Gieben <miek@miek.nl>

* typos in comments

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-06 21:18:11 +00:00
Daniel Garcia
f51c110511 Use TrimPrefix instead of TrimLeft in rewrite prefix plugin (#2364) (#2370) 2018-12-06 21:02:07 +00:00
Chris O'Haver
9a393ac5c8 clean pre-submit checks (#2367)
Automatically submitted.
2018-12-05 21:20:20 +00:00
Chris O'Haver
b53cc51f53 plugin/loop: Improve loop troubleshoot docs (#2363)
* improve loop troubleshoot docs

* fix spelling
2018-12-04 11:58:20 +00:00
Yong Tang
e5f5da4297 Update Prometheus to 0.9.1 (#2360)
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2018-12-01 22:38:03 +00:00
Miek Gieben
4c86e546ac
plugin/forward: remove truncate logic (#2320)
I think this is causing problem and it will actually clash with the
scrubbing that now happens for all plugins anyway. We're assuming the
returned message will be valid even with tc being set. request.Scrub
follows that same logic.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-12-01 09:07:42 +00:00
Miek Gieben
bae9514e94
pkg/up: implement backoff (#2342)
* pkg/up: implement backoff

Every 2nd failure we double the interval until we hit 4 * interval. This
to have some sort of backoff, esp when a large cluster of coredns shares
an upstream (original intent of up package) they will hammer the
upstream. This put some back pressure on that.

Signed-off-by: Miek Gieben <miek@miek.nl>

* Update plugin/pkg/up/up.go

Co-Authored-By: miekg <miek@miek.nl>
2018-12-01 09:07:03 +00:00
Chris O'Haver
41c5cf4424
allow ttl 0 (#2348) 2018-11-30 13:05:49 -05:00
Miek Gieben
50ef7409d1
Up to DNS version 1.1.0 (#2346)
Upgrade to new dns lib version; that saw multiple improvements; some
patch releases are in the pipeline.

The big thing here is the removal of ErrTruncated, so we need to deal
with this slightly different in the forward plugin. It removed the
entire truncated.go logic and just checks the message for .Truncated (if
there is a message) and retries with tcp.

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-11-29 20:02:32 +00:00
Cricket Liu
39ad7e499e Update README.md (#2344)
Textual cleanup.
2018-11-28 19:57:39 +00:00
Cricket Liu
bf67c9134c Update README.md (#2341)
Miscellaneous textual cleanup.
2018-11-27 14:28:20 -05:00
Miek Gieben
2032586399 Scrub results in forwarding/lookup (#2331)
Signed-off-by: Miek Gieben <miek@miek.nl>
2018-11-23 05:29:25 +09:00
Jiacheng Xu
fc96c64263 Add the missed braces. (#2330) 2018-11-21 07:44:17 -08:00
John Belamaric
9d41fa663c Do not muck with ordering of XFRs (#2329)
The loadbalancer plugin reorders records. It was doing this for zone
transfers - if you had a CNAME in the zone then your transfer would
be broken because it would get put before the SOA record.
2018-11-21 08:38:19 +01:00
Miek Gieben
973349592e plugin/forward: make tls config more clear (#2326)
Automatically submitted.
2018-11-20 20:16:54 +00:00
Miek Gieben
a1d92c51cd
plugin/forward: remove dynamic read timeout (#2319)
* plugin/forward: remove dynamic read timeout

We care about an upstream being there, so we still have a dynamic dial
time out (by way higher then 200ms) of 1s; this should be fairly stable
for an upstream. The read timeout if more variable because of cached and
non cached responses. As such remove his logic entirely.

Drop to 2s read timeout.

Fixes #2306

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-11-20 08:48:56 +01:00
stuart nelson
8dbe1fbee2 Set SOA record TTL as min of TTL/MINIMUM (#2295)
* Set SOA record TTL as min of TTL/MINIMUM

According to
https://tools.ietf.org/html/rfc2308#section-3:

  The TTL of this record is set from the minimum
  of the MINIMUM field of the SOA record and the
  TTL of the SOA itself, and indicates how long a
  resolver may cache the negative answer.

Set the TTL accordingly so as to not always
negative cache SOA records for 300 seconds.

* Inline min func

* Update SOA record tests

* Fix types
2018-11-16 08:42:49 -05:00
Miek Gieben
3f6dfba1f0
Redo the plugin log PR (#2315)
* Redo the plugin log PR

Remove the code duplication and call of the "official" functions. This
is the second(?) time we forgot to update the other half, so remove that
problem entirely.

Also add a test if the correct (within limits) time in front of the log
line.

Signed-off-by: Miek Gieben <miek@miek.nl>

* Remove pFormat

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-11-15 22:18:49 +00:00
Chris O'Haver
7aafbe24ca plugin/kubernetes: Validate transfers are allowed (#2292)
* check allowed transfers

* add tests for parsing, and comment about refactor
2018-11-13 23:25:30 +00:00
Miek Gieben
944c3e6a94
pkg/log: use 000 instead of 999 for the millis (#2303)
999 chops of suffix zero, 000 allows for the milliseconds to be always
printed with 3 chars. This makes the log the printed with the same
columns.

(partial logs below)

2018-11-13T21:13:28.249Z [INFO] [::1]
2018-11-13T21:13:48.414Z [INFO] [::1]
2018-11-13T21:13:49.1Z [INFO] [::1]

vs:

2018-11-13T21:20:22.262Z [INFO] [::1]
2018-11-13T21:20:22.436Z [INFO] [::1]
2018-11-13T21:20:22.608Z [INFO] [::1]

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-11-13 23:22:32 +00:00
Yong Tang
bb0b60ec81 Update README.md in route53 plugin (#2299)
Update README.md in route53 plugin, as credentials_file is
not supported.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2018-11-13 22:44:47 +00:00
Sandeep Rajan
c3d69bec31 fix formatting (#2302) 2018-11-13 16:46:48 -05:00
Francois Tur
94c9aae323 plugin/log - Support for Metadata (#2251)
* - add metadata support to Log

* - adapt ctx after rebase
2018-11-13 11:20:49 -08:00
Chris O'Haver
d97b257f8d dont log error for non existant txt records (#2291) 2018-11-12 16:34:32 +00:00
Chris O'Haver
cc82915f93 recommended (#2283)
Automatically submitted.
2018-11-09 20:32:43 +00:00
DavadDi
12e18a263f add missed kubernetes option to syntax box (#2281) 2018-11-08 07:38:47 -05:00
DavadDi
bad135cdc5 add opts.initPodCache to avoid panic (#2279)
Automatically submitted.
2018-11-07 20:53:05 +00:00
Jiacheng Xu
ae7fbf31d6 Fix a typo in health plugin readme (#2274) 2018-11-06 08:54:53 -08:00
moredhel
b7bbfef6ef fix typo (#2272) 2018-11-05 05:59:24 -08:00
Miek Gieben
c2331d7dda plugin/host: parse file without holding lock (#2270)
* plugin/host: parse file without holding lock

Parse first and then swap the maps *while* holding the lock.

Signed-off-by: Miek Gieben <miek@miek.nl>

* add back in the parse function, but now purely for testing

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-11-03 13:00:07 -07:00
Miek Gieben
921b02e2d5 plugin/log: explain the {size} better (#2269)
This is now the raw size which may be larger than what a particular
client actually sees.

Clarify this a bit.

Fixes #2258

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-11-03 11:58:15 -07:00
Jiacheng Xu
165b4f86a3 plugin/route53: make the upstream address in route53 plugin optional. (#2263)
* Make the upstream in route53 plugin optional.

Signed-off-by: Jiacheng Xu <xjcmaxwellcjx@gmail.com>

* Add 2 tests for upstream in route53.

Signed-off-by: Jiacheng Xu <xjcmaxwellcjx@gmail.com>

* Change the readme.

Signed-off-by: Jiacheng Xu <xjcmaxwellcjx@gmail.com>
2018-11-02 21:07:50 +00:00
Jiacheng Xu
1a01e13db8 plugin/etcd: make the address of upstream optional (#2262)
Automatically submitted.
2018-11-02 19:52:12 +00:00
Francois Tur
05204ef142 Metrics registered on wrong prometheus registry (#2246)
* - UT on metrics verifying that all plugins of all blocs have their metrics collectors declared

* - fix error msg

* - redirect Registry of metric to the one that handle the listener
- allow duplicate of metrics collector on the same Registry (case of same plugin in 2 blocs listening metrics on the same address)

* - fix change of signature

* - ensure cleaning metrics before starting the test (metrics collectors are global vars .. and re-used by several tests)

* - I think I fixed this test. Ensure correct mn of hits and clean metrics before test.

* - fix typo in error msg - proposed at review

* - fix typo in comment

* - remove ResetMetrics functions
- change a way to test the numeric metrics : get the diff between begin and end of test

* - oops. removing debug logs
2018-11-01 19:56:00 +00:00
Chris O'Haver
f5aa6cac67 remove trailing whitespace (#2260) 2018-11-01 19:37:13 +00:00