Commit graph

55 commits

Author SHA1 Message Date
JoeWrightss
92b7136684 Fix some typos in comment (#2599)
Signed-off-by: zhoulin xie <zhoulin.xie@daocloud.io>
2019-02-22 09:14:03 -05:00
Guy Templeton
d571fbe046 Correct formatting of policies list (#2509) 2019-01-28 10:07:13 -05:00
Miek Gieben
9c16ed1d14
Default to upstream to self (#2436)
* 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>
2019-01-13 16:54:49 +00:00
Francois Tur
f9bdd382dd Ensure Re-register of metrics variables after a reload (#2080)
* - ensure plugins that use prometheus.MustRegister, re-register after reload
- removing once.Do on the startup function was simplest way to do it.

* - fix underscored names (advice of bot)

* - tune existing UT for reload, and add a test verifying failing reload does not prevent correct registering for metrics

* - ensure different ports for tests that can run in same time ..
2018-09-19 02:11:24 -07:00
Miek Gieben
cb932ca231
Better naming (#2104)
* Move functions from pkg/transport to pkg/parse

Although "parse" is a fairly generic name I believe this is somewhat
better named. pkg/transport keeps a few constants that are uses
throughout for the rest is is renaming a bunch (and the fallout from
there to make things compile again).

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

* Fix tests

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-09-19 08:16:04 +01:00
dilyevsky
4ac06a342b
[plugin/proxy]: Return on WriteMsg err. (#2096)
* [plugin/proxy]: Return on WriteMsg err.

Followup PR on the heels of #2050. Short-circut and log on error from
`WriteMsg`. This will prevent code getting stuck on `ReadMsg` and allow
for easier debugging.

Also simply the `ReadMsg` calling code a little - remove double `Close` (already called above).
2018-09-17 10:21:12 -07:00
Miek Gieben
ba1efee4f1
Default to scrubbing replies in the server (#2012)
Every plugin needs to deal with EDNS0 and should call Scrub to make a
message fit the client's buffer. Move this functionality into the server
and wrapping the ResponseWriter into a ScrubWriter that handles these
bits for us. Result:

Less code and faster, because multiple chained plugins could all be
calling scrub and SizeAndDo - now there is just one place.

Most tests in file/* and dnssec/* needed adjusting because in those unit
tests you don't see OPT RRs anymore. The DNSSEC signer was also looking
at the returned OPT RR to see if it needed to sign - as those are now
added by the server (and thus later), this needed to change slightly.

Scrub itself still exist (for backward compat reasons), but has been
made a noop. Scrub has been renamed to scrub as it should not be used by
external plugins.

Fixes: #2010

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-08-29 12:26:22 +01:00
Karsten Weiss
6d8a078704 Typo fixes (#2031) 2018-08-14 08:55:55 -07:00
Yong Tang
54ec78c1ba Fix ineffassign (#1959)
* Fix ineffassign

This fix tries to fix ineffassign, as was reported in:
https://goreportcard.com/report/github.com/coredns/coredns#ineffassign

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

* Update setup.go

Revert this one change, so this can be merged.
2018-07-28 10:32:13 +01:00
Miek Gieben
f3134da45e
Clean up tests logging (#1979)
* Clean up tests logging

This cleans up the travis logs so you can see the failures better.

Older tests in tests/ would call log.SetOutput(ioutil.Discard) in
a haphazard way. This add log.Discard and put an `init` function in each
package's dir (no way to do this globally). The cleanup in tests/ is
clear.

All plugins also got this init function to have some uniformity and kill
any (future) logging there in the tests as well.

There is a one-off in pkg/healthcheck because that does log.

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

* bring back original log_test.go

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

* suppress logging here as well

Signed-off-by: Miek Gieben <miek@miek.nl>
2018-07-19 16:23:06 +01:00
Miek Gieben
41c724780f
remove deprecated code (#1888)
This removes:
* reverse plugin from plugin.cfg
* https_google option from proxy
* the -log flag
2018-06-20 11:35:07 +01:00
Miek Gieben
177e32b62e plugin/forward: add REFUSED test (#1878)
add a test to see if we copy the rcode correctly. Some minor cleanup in
import ordering and renaming NewUpstream to New as we already are in the
upstream package.
2018-06-15 08:12:56 -07:00
Miek Gieben
2758a756dd
Implement deprecation notice for 1.1.4 (#1833)
* Implement deprecation notice for 1.1.4

This still allows all the config to be parsed, but noops it:

* -log; always set the log to stdout; no matter what.
* https_google; removed from the proxy implementation.
* reverse plugin: set to deprecated.

* Whole of reverse can go

* Remove test for deprecated plugin
2018-05-24 14:30:01 +01:00
Chris O'Haver
afed91646a
plugin/proxy: fix except example (#1796)
I just noticed this discrepancy in one of the `except` examples.
2018-05-11 13:51:21 -04:00
Miek Gieben
643550eabe presubmit: check for uppercase (#1774)
Another thing we can test automatically, we sorta settled on using an
uppercase letter in in t.Log and t.Fatal calls.

Let's just check for this.
2018-05-07 23:47:25 +02:00
Miek Gieben
5735292406
Do Compress only when need in request.Scrub (#1760)
* Remove Compress by default

Set Compress = true in Scrub only when the message doesn not fit the
advertized buffer. Doing compression is expensive, so try to avoid it.

Master vs this branch
pkg: github.com/coredns/coredns/plugin/cache
BenchmarkCacheResponse-2   	   50000	     24774 ns/op

pkg: github.com/coredns/coredns/plugin/cache
BenchmarkCacheResponse-2   	  100000	     21960 ns/op

* and make it compile
2018-05-01 21:04:06 +01:00
Miek Gieben
7a507e34ca
deprecate some stuff (#1732)
https_google and reverse will be removed in 2 releases. Add warnings.

We will move reverse to coredns/reverse and list it as external after
this switch.

See #1713
2018-04-25 12:38:04 +01:00
Miek Gieben
12b2ff9740
Use logging (#1718)
* update docs

* plugins: use plugin specific logging

Hooking up pkg/log also changed NewWithPlugin to just take a string
instead of a plugin.Handler as that is more flexible and for instance
the Root "plugin" doesn't implement it fully.

Same logging from the reload plugin:

.:1043
2018/04/22 08:56:37 [INFO] CoreDNS-1.1.1
2018/04/22 08:56:37 [INFO] linux/amd64, go1.10.1,
CoreDNS-1.1.1
linux/amd64, go1.10.1,
2018/04/22 08:56:37 [INFO] plugin/reload: Running configuration MD5 = ec4c9c55cd19759ea1c46b8c45742b06
2018/04/22 08:56:54 [INFO] Reloading
2018/04/22 08:56:54 [INFO] plugin/reload: Running configuration MD5 = 9e2bfdd85bdc9cceb740ba9c80f34c1a
2018/04/22 08:56:54 [INFO] Reloading complete

* update docs

* better doc
2018-04-22 21:40:33 +01:00
Miek Gieben
0930eb8beb
all: fix plugin import ordering (#1717)
Got a bit messed up with stb lib "context" usage.
2018-04-22 08:34:35 +01:00
Miek Gieben
8722336fff
global: move to context (#1699)
* global: move to context

Move from golang.org/x/net/context to std lib's context.

Change done with:

for i in $(grep -l '/context' **/*.go); do sed -e 's|golang.org/x/net/context|context|' -i $i; echo $i; done
for i in **/*.go; do goimports -w $i; done

* drop from dns.pb.go as well
2018-04-20 11:01:06 +01:00
Miek Gieben
61726b3721
Run make -f Makefile.doc (#1705)
Remove trailing white space from proxy/README.md
2018-04-20 07:24:19 +01:00
Scott Donovan
19a1ef48f2 adding sequential policy to forward plugin (#1704)
* adding sequential policy to forward plugin

* making sequential an alias to first in proxy plugin
2018-04-20 07:07:58 +01:00
Miek Gieben
26d1432ae6
Update all plugins to use plugin/pkg/log (#1694)
* Update all plugins to use plugin/pkg/log

I wish this could have been done with sed. Alas manually changed all
callers to use the new plugin/pkg/log package.

* Error -> Info

* Add docs to debug plugin as well
2018-04-19 07:41:56 +01:00
Miek Gieben
08443a9f00
plugin/metrics: add 'server' label (#1682)
* plugin/metrics: add 'server' label

This uses the new WithServer(ctx) to get the current server from the
context.

First in a larger refactor to make all plugins do this.

* compile

* compile

* lala test

* compile and test

* typos

* Dont duplicate the code
2018-04-18 09:42:20 +01:00
Francois Tur
5a546f743e Plugin/Proxy - update README (#1658)
* - adding policy first in the policies description

* - fix number of policies available
2018-04-06 15:53:08 +01:00
Miek Gieben
2338120f5b
plugin/metrics: add MustRegister function (#1648)
This registers the Collectors iff the metrics plugin has been loaded.
Safes a bunch of code in each and every plugin's setup code.
2018-04-01 13:58:13 +01:00
Miek Gieben
fd1501e918
plugin/{forward,proxy}: check for truncated (#1644)
Check for trunacted in the lookup function as well and use the Match
function here as well.
2018-03-31 15:31:03 +01:00
Miek Gieben
5616fcb175
Fix dns-01-003 (#1634)
* plugin/{cache,forward,proxy}: don't allow responses that are bogus

Responses that are not matching what we've been querying for should be
dropped. They are converted into FormErrs by forward and proxy; as a 2nd
backstop cache will also not cache these.

* plug

* add explicit test
2018-03-25 17:11:10 +01:00
varyoo
6bb08ffee4 Easier way to dnstap? (#1496)
* Easier way to dnstap?

* Remove unnecessary function parameter from Tapper

* golint

* golint 2

* Proxy dnstap tests

* README.md & doc

* net.IP

* Proxy test was incorrect

* Small changes

* Update README.md

* Was not reporting dnstap errors + test

* Wasn't working at all, now it's ok

* Thanks Travis
2018-02-28 18:19:01 -08:00
Freddy
86be6d2532 remove coredns-grpc reference and update DnsService link (#1542) 2018-02-19 15:29:20 +00:00
Miek Gieben
8b035fa938
Fix imports (#1528) 2018-02-14 21:29:00 +01:00
Francois Tur
ee8084a08f Plugin/Proxy - prevent nil pointer when query using a gRPC client that could not dial in (#1495)
* prevent nil pointer when query frpc client that could not open

* add UT checking we can now safely request DNS query on an invalid hostname, query for gRPC connection

* fix ortograph

* fix format

* fix package declaration, fix UT - grpclogger, use fatalf, build pool with known addresses

* type, useless error check - after review
2018-02-14 20:20:27 +01:00
Miek Gieben
fd7abd9849
Add OWNERS file (#1486)
This should have everyone, but the process was quite manual. The rename
from middleware -> plugin also meant I had to do some extra digging on
who actually submitted the PR. I also double checked the current list of
people with commit access.

Every plugin now has an OWNERS, except *reverse*. I'll file a bug for
that.
2018-02-08 10:55:51 +00:00
Francois Tur
b93a36b213 Plugin/Proxy - add new policy always_first to mimic windows dns resolvers (#1459)
* add new policy always_first to mimic windows dns resolvers
fill documentation, add UT and cleanup fmt

* change name of policy from always_first to first. Update docs
2018-01-30 16:29:49 -05:00
Tobias Schmidt
0af9b9b16f plugin/proxy: Fix unnecessary message truncation (#1477)
As plugin/proxy always returns compressed messages, it's important to
set this before calling Scrub(), as some messages will be unnecessarily
truncated otherwise.
2018-01-30 23:18:44 +02:00
Miek Gieben
f91cb61086 Don't use standard lib context package (#1468)
With Go 1.9 you *can* include the std lib's context package and nothing
breaks. However we never officially made the move (and grpc also doesn't
ues the std lib's one).

Standardize all plugins on using the extern context package.

Fixes #1466
2018-01-30 09:19:37 -05:00
John Belamaric
d27be86e3e
Minor refactor of proxy parsing to make upstreams re-usable in other plugins (#1426) 2018-01-27 17:25:39 -05:00
Miek Gieben
b7476d0217
Doc (#1369)
* Constent atx headers

* Regen manual pages
2018-01-10 11:45:12 +00:00
Miek Gieben
a7590897fb
plugin/proxy: max the number of upstreams (#1359)
* plugin/proxy: max the number of upstreams

Put a max of 15 on the number of upstreams.
2018-01-08 15:03:42 +00:00
Miek Gieben
58221f55db
Manual pages (#1346)
* Add manual pages

Generate manual pages from the README and extend README with Name and
Description sections.

The generation requires 'ronn' which may not be available. Just check in
all generated manual pages.
2018-01-04 12:53:07 +00:00
Miek Gieben
90dd4bbd45
metrics: correctly register all metrics (#1335)
After initial startup, see if prometheus is loaded and if so, register
our metrics with it.
Stop doing the init() func and just use the sync.Once so we don't double
registrer our metrics.
2017-12-27 15:48:14 +00:00
Miek Gieben
a8ba24fff9 plugin/proxy: for duration metrics (#1323)
The README.md was updated by not the actual metric.

Fixes #1321
2017-12-20 18:25:43 -05:00
Miek Gieben
0e8ceea1d6
plugin/proxy: skip hc for https_google (#1272)
If protocol is https_google we do the health checks wrong, i.e. we're healthchecking the wrong
endpoint, hence the health check code below should not be executed. See issue #1202.
This is an ugly hack and the thing requires a rethink. Possibly in conjunction with moving
to the *forward* plugin.
2017-12-07 22:25:05 +00:00
Miek Gieben
0d103ff57c
plugin/proxy: add note about HC and google_https (#1269)
HC for google_https does not work because it does not HC the correct
set of IPs. Hard to solve in the current code - rather use forward as
the new impl. and leave this as legacy.

Remove superfluous println that we are refreshing the dns.google.com IP
address.
2017-12-01 13:21:18 +00:00
Miek Gieben
917965fa86
metrics: use exponentional buckets (#1261)
* metrics: use exponentional buckets

See  https://github.com/kubernetes/dns/pull/168
2017-12-01 11:15:05 +00:00
Ben Kochie
06006fac56 Update timing histograms (#1253)
* Use seconds for bucketing.
* Add template for high accuracy timing buckets to avoid copy-pasta.
2017-11-27 21:34:26 +00:00
Miek Gieben
0186aadfcf
fuzz: put fuzzing stuff in own build tag (#1215)
No need to have this build all the time.
2017-11-10 13:59:42 +00:00
Miek Gieben
c2d93f7182 plugin/dnstap: some cleanup (#1172)
Some cleanup in proxy and dnstap:
* just use time pkg directly and side step the indirection for Epoch
* Use Set in SetQueryEpoch to be more Go like. (Looked like a reader)
* Don't maintain two sets of time, we already track start, so use that.
* Use time.Time and convert when needed
* dedent the toDnstap function and put in a separate file
2017-10-25 19:46:41 +01:00
Miek Gieben
e34e2c251f plugin/proxy: kick of HC on every 3rd failure (#1110)
* healthchecks: check on every 3rd failure

Check on every third failure and some cleanups to make this possible. A
failed healthcheck will never increase Fails, a successfull healthceck
will reset Fails to 0. This is a chance this counter now drops below 0,
making the upstream super? healthy.

This removes the okUntil smartness and condences everything back to 1
metrics: Fails; so it's simpler in that regard.

Timout errors are *not* attributed to the local upstream, and don't get
counted into the Fails anymore. Meaning the 'dig any isc.org' won't kill
your upstream.

Added extra test the see if the Fails counter gets reset after 3 failed
connection.

There is still a disconnect beween HTTP healthceck working the proxy (or
lookup) not being able to connect to the upstream.

* Fix tests
2017-10-15 19:38:39 +02:00
Miek Gieben
7c6ba3fcbd plugin/proxy: fix metrics (#1137)
Add Counter metrics and fix duration to use upstream name (and only use
it when we have one).

Fix the documentation to reflect this.

Fixes #1134
2017-10-08 04:30:44 -07:00