Commit graph

252 commits

Author SHA1 Message Date
Miek Gieben
d49194623f
plugin/forward: remove lenc and lencOut channels (#1726)
Remove these 2 channels, as they were only used in testing and
complicate things if we want to do a clean stop()

Less is more.
2018-04-24 16:10:31 +01:00
Miek Gieben
eb7c3ad137
Build manual docs (#1721)
Slight tweak in the forward readme, as sublist don't work well to
generate these.
2018-04-23 12:47:32 +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
69a956f052
plugin/pkg/log: add plugin logging (#1716)
Add per plugin logging to make it explicit what is logging, if you
include this package under the name clog (coredns log), you can do the
following:

log := clog.NewWithPlugin{whoami{}} // e.g.

And then just log.Info(...); these will then include the plugin ala:
[INFO] plugin/whoami: stuff

So we only need to init the logger and then just use it.
2018-04-22 08:20:01 +01:00
Miek Gieben
a466bb6fc6
Export metrics in setup; so it also works after reload (#1715)
* brr; a sleep

* Shouldnt need a query
2018-04-21 18:59:35 +01:00
Miek Gieben
acbcad7b4e
reload: use OnRestart (#1709)
* reload: use OnRestart

Close the listener on OnRestart for health and metrics so the default
setup function can setup the listener when the plugin is "starting up".

Lightly test with some SIGUSR1-ing. Also checked the reload plugin with
this, seems fine:

.com.:1043
.:1043
2018/04/20 15:01:25 [INFO] CoreDNS-1.1.1
2018/04/20 15:01:25 [INFO] linux/amd64, go1.10,
CoreDNS-1.1.1
linux/amd64, go1.10,
2018/04/20 15:01:25 [INFO] Running configuration MD5 = aa8b3f03946fb60546ca1f725d482714
2018/04/20 15:02:01 [INFO] Reloading
2018/04/20 15:02:01 [INFO] Running configuration MD5 = b34a96d99e01db4015a892212560155f
2018/04/20 15:02:01 [INFO] Reloading complete
^C2018/04/20 15:02:06 [INFO] SIGINT: Shutting down

With this corefile:
.com {
  proxy . 127.0.0.1:53
  prometheus :9054
  whoami
  reload
}

. {
  proxy . 127.0.0.1:53
  prometheus :9054
  whoami
  reload
}

The prometheus port was 9053, changed that to 54 so reload would pick it
up.

From a cursory look it seems this also fixes:
Fixes #1604 #1618 #1686 #1492

* At least make it test

* Use onfinalshutdown

* reload: add reload test

This test #1604 adn right now fails.

* Address review comments

* Add bug section explaining things a bit

* compile tests

* Fix tests

* fixes

* slightly less crazy

* try to make prometheus setup less confusing

* Use ephermal port for test

* Don't use the listener

* These are shared between goroutines, just use the boolean in the main
  structure.
* Fix text in the reload README,
* Set addr to TODO once stopping it
* Morph fturb's comment into test, to test reload and scrape health and
  metric endpoint
2018-04-21 17:43:02 +01:00
Ruslan Drozhdzh
135377bf77
plugin/forward: gracefull stop (#1701)
* plugin/forward: gracefull stop

 - stop connection manager only when no queries in progress

* minor improvement

* prevent healthcheck on stopped proxy

* revert closing channels

* use standard context
2018-04-20 17:47:46 +03:00
Miek Gieben
ad13d88346
plugin/health: clarify server label (#1707)
Health overloaded metrics does not carry the server label. Explain why.
2018-04-20 15:03:59 +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
b4b65fbc18
pkg/log: ability for debug logs (#1689)
* pkg/log: ability for debug logs

When the debug plugin is enabled all log.Debug calls will print to
standard; if not there are a noop (almost).

The log package wraps some standard log functions as well, so just
replacing "log" with "plugin/pkg/log" should be enough to use this
package.

* docs

* Add docs

* lint

* Test fallthrough to log pkg as well

* simple package - up test coverage

* add other log levels as well

* update docs
2018-04-18 21:02:01 +01:00
Chris O'Haver
51e1442bd9
plugin/kubernetes: check for bare zone query (#1692)
* check for bare zone query

* check for bare type query
2018-04-18 12:12:28 -04:00
Chris O'Haver
9a7e487a5a Update README.md (#1690) 2018-04-18 15:17:14 +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
Miek Gieben
573ad62b77 plugin/forward: min and max for avgRTT (#1680)
* Move to readtimeout

* lets compile

* address comment

* comment from pr

* much smaller minimum
2018-04-16 14:51:49 -04:00
Miek Gieben
cff0c9fb4c
plugin/forward: test TLS setup (#1677) 2018-04-13 17:02:54 +01:00
Miek Gieben
662edf6607
pkg/up: stop *all* goroutines (#1676)
Stop all goroutines after we get the stop signal.
2018-04-13 16:01:12 +01:00
Tobias Schmidt
e671e22e65 plugin/forward: Return original message on truncation (#1674)
With this change the original truncated message returned by requested
server is returned to the client, instead of returning an empty dummy
message with only the truncation bit set.
2018-04-12 20:17:05 +01:00
Miek Gieben
305ae9b9bc
plugin/forward: check TC correctly on reply. (#1670)
* plugin/forward: check TC correctly on reply.

Add test for this.

* Add proxy test as well
2018-04-11 21:18:41 +01:00
Maksim Paramonau
9ae9ee4b6b fix readme.md of log plugin (#1668) 2018-04-11 19:07:10 +01:00
Ruslan Drozhdzh
a0f294e550 plugin/forward: add query timeout (#1665) 2018-04-11 07:53:08 +01:00
Maksim Paramonau
ccfe691b95 plugin/log: allow various combinations of classes of responses (#1664)
This allows to log responses of different classes, for example, denial and error.
2018-04-11 07:50:16 +01:00
Ruslan Drozhdzh
a20b4fe2de plugin/forward: use dynamic read timeout (#1659)
- each proxy stores average RTT (round trip time) of last rttCount queries.
   For now, I assigned the value 4 to rttCount
 - the read timeout is calculated as doubled average RTT, but it cannot
   exceed default timeout
 - initial avg RTT is set to a half of default timeout, so initial timeout
   is equal to default timeout
 - the RTT for failed read is considered equal to default timeout, so any
   failed read will lead to increasing average RTT (up to default timeout)
 - dynamic timeouts will let us react faster on lost UDP packets
 - in future, we may develop a low-latency forward policy based on
   collected RTT values of proxies
2018-04-11 07:50:06 +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
Ruslan Drozhdzh
e46ee9d9cc plugin/forward: retry on cached tcp connection closed by peer (#1655)
* plugin/forward: retry on cached tcp connection closed by peer

* fix linter warnings

* fixed unit test

* modify error message
2018-04-06 13:41:48 +01:00
Miek Gieben
81348b420b
plugin/forward: TCP conns can be closed (#1651)
* plugin/forward: TCP conns can be closed

Only when we read and get a io.EOF we know the conn is closed (for TCP).
If this is the case Dial (again) and retry. Note that this new
connection can also be closed by the upstream, we may want to add a
DialForceNew or something to get a new TCP connection..

Simular to #1624, *but* this is by (TCP) design. We also don't have to
wait for a timeout which makes it easier to reason about.

* Move to forward.go

* doesnt need changing
2018-04-01 16:18:21 +01:00
Miek Gieben
5f98e98107
plugin/proxy: return client error (#1646)
Return the client error if there was one instead of the generic
"no healthy upstream or error"
2018-04-01 14:23:40 +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
4df416ca1d
Metrics (#1579)
* plugin/metrics: set server address in context

Allow cross server block metrics to co-exist; for this we should label
each metric with the server label. Put this information in the context
and provide a helper function to get it out.

Abstracting with entirely away with difficult as the release client_go
(0.8.0) doesn't have the CurryWith functions yet. So current use is like
so:

define metric, with server label:

	RcodeCount = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: plugin.Namespace,
		Subsystem: "forward",
		Name:      "response_rcode_count_total",
		Help:      "Counter of requests made per upstream.",
	}, []string{"server", "rcode", "to"})

And report ith with the helper function metrics.WithServer:

	RcodeCount.WithLabelValues(metrics.WithServer(ctx), rc, p.addr).Add(1)
2018-04-01 13:57:03 +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
Ruslan Drozhdzh
f19a3b24ca plugin/forward: improve tls configuration (#1643) 2018-03-30 14:35:09 +01:00
Miek Gieben
6d272e3174
plugin/forward: set the RD bit in the hc (#1639)
My routers acts funny when it sees it non RD query; make this HC as
boring as possible
2018-03-26 21:23:33 +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
John Belamaric
91413c25e1 Make examples complete Corefiles (#1623) 2018-03-25 16:48:57 +01:00
Yong Tang
55824516bd
Add PTR record support for Route53 plugin (#1606)
This fix adds PTR record support for Route53 plugin

This fix fixes 1595

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2018-03-13 15:10:07 -07:00
Chris O'Haver
e5beb9dbfc Update README.md (#1607) 2018-03-13 16:33:11 -04:00
Ricardo Katz
3bb4e659b2 Document the service with ClusterIP wildcard (#1605)
This PR documents the trick exposed in coredns/coredns#1357 about using wildcards to get all POD IPs from a service with ClusterIP (as used in 'endpoints')
2018-03-13 14:35:29 +00:00
Yong Tang
3e3d8cc845 Fix incorrect test case in rout53 plugin (#1603)
While looking into route53 plugin I notice the test case
was incorrect and does not really test the reply. This
fix fixes the issue in the test.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2018-03-13 07:06:50 +00:00
Chris O'Haver
0daa03a81f exclude terminating pods (#1602) 2018-03-13 07:06:03 +00:00
Miek Gieben
27f58d8dc6
logging: Don't use PrintF when not needed (#1599)
These log print don't have any verbs, so just use plain Print
2018-03-09 20:42:27 +00:00
Yamil Asusta
87790dd47c Add DD support (#1596) 2018-03-09 15:08:57 -05:00
Miek Gieben
95342dfaad
plugin/kubernetes: make glog log to standard output (#1598)
Jump through all the hoops to make this work.
2018-03-09 19:55:43 +00:00
Miek Gieben
0353abd3f8
plugin/erratic: linkify RFC references (#1593)
Also add Also See Section.
2018-03-07 13:52:32 +00:00
Miek Gieben
804f745951
plugin/health: make reload work (#1585)
* plugin/health: make reload work

Remove the once.Do from the startup, so we can re-bind the HTTP
listener. Also clarify the usage of health in multiple server blocks
(this is not the best approach - but there isn't a generic solution at
this point).

Manual tested as we lack testing infra, i.e kill -SIGUSR1 and some
CURLing of the health endpoint.

* Readme test fix

* update

* dont need this
2018-03-02 21:40:14 -08:00
Miek Gieben
acf823cd78
Metrics2 (#1588)
* plugin/metrics: still need nil check for shutdown

the second prometheus statement will trigger: (on control-C)

[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x94f45a]

goroutine 25 [running]:
github.com/coredns/coredns/plugin/metrics.(*Metrics).OnShutdown(0xc420252000, 0x0, 0x0)
	/home/miek/g/src/github.com/coredns/coredns/plugin/metrics/metrics.go:107 +0x2a
github.com/coredns/coredns/plugin/metrics.(*Metrics).OnShutdown-fm(0x0, 0x0)
	/home/miek/g/src/github.com/coredns/coredns/plugin/metrics/setup.go:39 +0x2a
github.com/mholt/caddy.(*Instance).ShutdownCallbacks(0xc4202c81e0, 0x0, 0x0, 0x0)
	/home/miek/g/src/github.com/mholt/caddy/caddy.go:164 +0xb3
github.com/mholt/caddy.allShutdownCallbacks(0x1743935, 0x8, 0x14a1b40)
	/home/miek/g/src/github.com/mholt/caddy/sigtrap.go:95 +0x10d
github.com/mholt/caddy.executeShutdownCallbacks.func1()
	/home/miek/g/src/github.com/mholt/caddy/sigtrap.go:75 +0x8f
sync.(*Once).Do(0x2256b80, 0xc42036df88)
	/home/miek/upstream/go/src/sync/once.go:44 +0xbe
github.com/mholt/caddy.executeShutdownCallbacks(0x174033f, 0x6, 0x0)
	/home/miek/g/src/github.com/mholt/caddy/sigtrap.go:71 +0x73
github.com/mholt/caddy.trapSignalsCrossPlatform.func1.1()
	/home/miek/g/src/github.com/mholt/caddy/sigtrap.go:61 +0x36
created by github.com/mholt/caddy.trapSignalsCrossPlatform.func1
	/home/miek

* comments on why
2018-03-02 18:17:05 -08:00
Miek Gieben
6cec66ce40
plugin/reload: enable (#1587)
Couldn't revert the original commit, just manually perform the needed
tweaks.
2018-03-02 17:17:26 -08:00
Miek Gieben
6f3a7af548
Metrics reload (#1586)
* wip

* plugin/metrics: fix reload behavior

Fixes #1472
2018-03-02 17:16:25 -08:00