Commit graph

164 commits

Author SHA1 Message Date
Miek Gieben
be47709270 More Middleware -> Plugin conversions (#1088)
Forgot about these.
2017-09-16 14:13:28 +01:00
Miek Gieben
d8714e64e4 Remove the word middleware (#1067)
* Rename middleware to plugin

first pass; mostly used 'sed', few spots where I manually changed
text.

This still builds a coredns binary.

* fmt error

* Rename AddMiddleware to AddPlugin

* Readd AddMiddleware to remain backwards compat
2017-09-14 09:36:06 +01:00
Miek Gieben
3e252deabb Remove debug queries (#1058)
* Remove debug from interface and methods

* remove debug queries from etcd

* remove debug queries from k8s - they were not used

* And remove from mw/proxy-google as well

* Remove debug query test
2017-09-12 10:52:43 +01:00
Miek Gieben
2785f01db5 core: readme test: new port for every instance (#1056)
Use a new port for every instance.
2017-09-10 20:29:38 +01:00
Miek Gieben
6e3eec1e72 documention: test README snippets (#1043)
If a README has a corefile snippet that is annotated with `corefile`,
this test will parse the instance and checks the snippet is legal.
This means a) we will get better docs b) we know for sure everything
still parses.

The test parses everything in middleware/*/README.md, it does not check
for README presence, just Corefile snippets. The port used is 10053 and
overrides whatever port is set in the docs.

The secondary middleware was used as an example and adds two examples
that should parse.

failures show up as:

~~~
--- FAIL: TestReadme (0.04s)
	readme_test.go:50: Testing ../middleware/secondary/README.md, with 100 byte snippet
	readme_test.go:50: Testing ../middleware/secondary/README.md, with 93 byte snippet
	readme_test.go:53: Failed to start server for input "middleware/secondary: Corefile:3 - Error during parsing: unknown property 'transfeT'":
		. {
		    secondary example.net {
		        transfeT from 10.1.2.1
		        transfer to *
		    }
		}
FAIL
~~~
2017-09-10 19:52:15 +01:00
Yong Tang
4b14243e9b Add k8s tags to related tests (#1018)
, so that `make test` will pass by default.

Also fixed several ineffassign and golint issues.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-09-01 19:21:05 +02:00
Miek Gieben
7d47af4f06 mw/kubernetes: move fallthrough tests out (#1008)
* mw/kubernetes: move fallthrough tests out

Remove the testcase duplication and put fallthrough tests in separate
file.

Also make some names shorter and more descriptive.

* fix test build

* fix corefile
2017-09-01 08:53:42 +02:00
Miek Gieben
3974071f48 mw/kubernetes: split integration tests (#1004)
* mw/kubernetes: split integration tests

* separate file and test for api fallthrough, does not need all other
  servers to be started.
* more split ups: make it clear when or when not we need an upstream server,
  as just needlessly start it in doIntegrationTests.
* use identifiers from dns package -> "TypeSRV" -> dns.TypeSRV, as there
  is no need to reinvent these.

* updates

* deploy work-around

* re-add weird sleep
2017-08-30 17:04:19 +02:00
Miek Gieben
9c56805d38 mw/etcd: use context.TODO() in tests (#1000)
Go vet warning: fix use of context.

Fixes #997

Also make *auto*'s reload test less flaky by retrying
and then giving up.
2017-08-27 07:39:44 +01:00
Miek Gieben
4049ed4f4b mw/kubernetes: add configurable TTL (#995)
* mw/kubernetes: add configurable TTL

Add ttl option to kubernetes. This defaults to 5s but allows
configuration to go up to 3600.

Configure the tests so that a few actually check for the 5s, while the
rest use the TTL of 303 which is ignored by the checking code.

Fixes #935

* fix tests

* and more
2017-08-26 17:32:46 -07:00
Miek Gieben
1bb836b793 mw/health: add reload test (#980)
Start CoreDNS instance in call Restart() on it.
2017-08-26 17:39:43 +01:00
Yong Tang
3a9cb4fcf8 Reduce the test cases for kubernetes API proxy (#989)
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-08-25 11:04:21 -07:00
Miek Gieben
932639ac99 Remove createTestServer (#981)
* Remove createTestServer

* more cleanups

* comment tweak

* sort

* sigh
2017-08-24 20:59:27 +01:00
Sandeep Rajan
5e9991556e Middleware/Kubernetes: Add RR check to K8s integration tests (#884) 2017-08-24 11:05:16 -04:00
Miek Gieben
f901b0cefa tests: CoreDNSServerAndPorts (#972)
* tests: CoreDNSServerAndPorts

Copy from kubernetes.go and renamed to fit the style, adapted almost
all callers.

This is a mechanicl change, no testdata was changed.

* typos
2017-08-24 11:35:14 +01:00
Miek Gieben
ea53f8c219 auto: test (#978)
Increate the sleep duration; this is not a proper fix. The problem here
is that this is in test that just starts a CoreDNS instance and thus we
don't have levers to make "time speed up". It might be worth checking if
there is some LD_PRELOAD hackery that fakes time for the entire test?

Fixes #945 (not really, but closing with this)
2017-08-24 09:18:27 +01:00
Miek Gieben
61fc672e19 mw/kubernetes: remove kPod and kServices (#969)
Based up on: #939, but redone in a new PR with some cherry-picked
commits:
aacb91ef0b
5dc34247b7

This removes kPod and Kservice and creates []msg.Service from k.findPods
and k.findServices.

Updated few tests which I *think* are correct; they look correct to me.
2017-08-23 07:19:41 +01:00
Miek Gieben
6a4e69eb9f mw/kubernetes: Rewrite parseRequest and Readability improvements (#939)
* mw/kubernetes: rewrite parseRequest

Stop looking at the qtype in parseRequest and make k.Namespace a map.
Fallout from this is that pkg/strings as it is not used anymore. Also
add a few helper functions to make unexposed namespaces easier to see in
the code.

Add wildcard tests to the middleware tests.

* Fix tests

Add a whole bunch of comments to document what we are trying to do.

* This is now answered

* up coverage

* duh

* Update testcase

* Make it nodata
2017-08-22 12:44:42 -07:00
Miek Gieben
f96cf27193 mw/federation: add federation back as separate mw for k8s (#929)
* mw/federaration

This PR add the federation back as a middleware to keep it more
contained from the main kubernetes code.

It also makes parseRequest less import and pushes this functionlity down
in the k.Entries. This minimizes (or tries to) the importance for the
qtype in the query. In the end the qtype checking should only happen
in ServeDNS - but for k8s this might proof difficult.

Numerous other cleanup in code and kubernetes tests.

* up test coverage
2017-08-18 14:45:20 +01:00
Miek Gieben
cc4e4a0626 mw/autopath: integration test with erratic (#930)
Add integration test with erratic. For this erratic now also returns an
autopath searchpath. This tests the whole chain; i.e registring a
searchfunction and calling that from autopath.

This tests does a autopathing domain and a non-autopathing one.
2017-08-18 12:57:23 +01:00
Miek Gieben
7f46df6d27 tests: add SortAndCheck helper (#926)
There was quite some code duplication in a lot of tests to check if
an answer was considered Ok. Created a test.SortAndCheck helper function
that takes care of this.
2017-08-16 15:30:58 +01:00
Miek Gieben
00f5c7797e mw/kubernetes: remove federation and cidr (#916)
* mw/kubernetes: remove federation and cidr

Remove both as we have a corefile syntax change that handles cidr and
remove federation because that is going to be its own middleware.

* backwards incompat changes

This PR:
* removes cidr from kubernetes (core Corefile feature now)
* removes federation from kubernets (comes back as new middleware)
* [remove autopath - which was already gone, so that already was
  backwards incompat]
* adds `fallthrough` to the *etcd* middleware and makes you enable it.
* Fail on unknown properties
* documentation
* Disable TestHealthCheck as it uses realtime and fails
2017-08-14 08:49:26 +01:00
Yong Tang
26d8680a11 Support multiple k8s api servers specification and load balance among api servers (#820)
* Support multiple k8s api servers specification and load balance among api servers

This fix adds supports for multiple k8s api servers specification,
load balance among api servers.

When two or more api servers are specified in kubernetes block (endpoint ...),
a proxy is created locally (with randomly generately port). The coredns
will points to the generated proxy so that load balancing could be achieved.

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

* Setup initial healthcheck at the beginning

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

* Update README.md for kubernetes middleware and remove whitespaces.

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

* Use middleware/pkg/healthcheck in middleware/kubernetes

for api proxy

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-08-10 17:14:56 -07:00
Miek Gieben
7e56cc74e5 WIP: Parserequest2 cutback (#868)
* middleware/kubernetes: pull TXT out of parseRequest

Put the TXT handling one layer higher and remove it from parseRequest.
Also rename the podsvc field in there to podOrSvc. Now that it isn't
used anymore for TXT record (dns-version) that was put in there. We can
make this a boolean (in a future PR).

Make parseRequest get an optional Zone that is from state.Zone and use
that instead of its own code. Removed some tests and other smaller
cleanups.

Fixes #836

* add this reverse

* another check

* readd

* Rename to kPod and kService for some clarity
2017-08-10 01:08:58 -07:00
Miek Gieben
e1c1521ad5 Core: convert IP addresses to reverse zone (#838)
* Core: convert IP addresses to reverse zone

If we see IP/mask syntax and the mask mod 8 == 0 we assume a reverse
zone and convert to in-addr or .arpa.

* typos

* integration test

* Addr is not used

* core: clean up normalize

Create a SplitHostPort function that can be used both from normalize.go
and address.go. This removes some (not all!) duplication between the
both and makes it work with reverse address notations.

* More tests
2017-08-07 13:24:09 -07:00
Miek Gieben
bcb2eb1ecc all: gometalinter (#843)
* kubernetes/reverse: remove deadcode
* deadcode in errors and kubernetes removed
* unnecessary conversion
* constants
* proxy: time.Since()
* simplications
* static check
* Disable test/external_test
2017-08-06 05:54:24 -07:00
Markus Sommer
d0d7f4c89a Kubernetes srv (#823)
* Treat absence of port/service in SRV as wildcard

Normally, a SRV-request should have the form
_<service>._<port>.<name>.<zone>. The k8s peer-finder which is used for
bootstrapping by some applications will however query for SRV at
<name>.<zone>.

To compensate for this behaviour, treat the absence of _<service> and
_<port> as wildcards.

* Modified tests with new SRV behaviour

Added a testcase for a SRV request without port & service
Removed now valid query from invalidSRVQueries

* Forgot to run gofmt on test/kubernetes_test.go
2017-08-04 09:41:55 -04:00
Miek Gieben
ea0a7d0076 test: add external compilation test (#803)
Pull down example middleware and compile it in (this should compile)
then check if dns.example is included in the list of plugins
(middlewares)
2017-07-29 04:04:12 -07:00
Miek Gieben
9fb266aebe middleware/secondary: multiple fixes (#745)
Fix transferring the zone from a master and the matching of notifies
to source and dst IP addresses.

Add `upstream` keyword as well, because it is needed for the same
reasons as in the *file* middlware.
Add some dire warning about upstream in the readme of both middlewares.

Out of band testing, hidden by net build tag was added. Integration
testing still needs to be setup.
2017-06-21 23:46:20 -07:00
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
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
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
Chris O'Haver
50f7573414 Add SOA record to upstream zone file (#689) 2017-06-01 21:22:45 +01: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
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
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
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
Miek Gieben
3b6eab2256 core: add reload tests (#622)
This adds a simple reload test for the UDP socket.
2017-04-18 11:25:21 +01:00
Miek Gieben
ef4fa66e67 middleware/file: add test for SRV additional (#616)
Add test for checking the additional section after a SRV query. Though
this wasn't fixed, but it is.

Fixes #609
2017-04-13 16:25:16 +01: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
Michael S. Fischer
dfc71df07d middleware/proxy: Allow non-HTTP upstreams to be health checked (#589)
Allow HTTP health check to be performed against a regular DNS upstream server.

TODO: Add tests.
2017-03-16 21:10:54 +00:00
Miek Gieben
5ac6020f45 Pr 586 tweaks (#594)
* add proxy tcp

* add truncated for tcp to udp response

* move truncation to scrubbing

* add test that executes upstream over tcp

* middleware/proxy: some tweaks

rename force-tcp to force_tcp to be inline with the rest and use
a dnsOptions struct to put the options in to allow it to be extended.
Add some parse tests as well.

* Fix test and rename dnsOptions Options
2017-03-14 21:32:21 +00:00
Miek Gieben
bfaf9e0aec core: add more transports (#574)
* core: add listening for other protocols

Allow CoreDNS to listen for TLS request coming over port 853. This can
be enabled with `tls://` in the config file.

Implement listening for grps:// as well.

a Corefile like:

~~~
. tls://.:1853 {
    whoami
    tls
}
~~~

Means we listen on 1853 for tls requests, the `tls` config item allows
configuration for TLS parameters. We *might* be tempted to use Caddy's
Let's Encrypt implementation here.

* Refactor coredns/grpc into CoreDNS

This makes gRPC a first class citizen in CoreDNS. Add defines as being
just another server.

* some cleanups

* unexport the servers

* Move protobuf dir

* Hook up TLS properly

* Fix test

* listen for TLS as well. README updates

* disable test, fix package

* fix test

* Fix tests

* Fix remaining test

* Some tests

* Make the test work

* Add grpc test from #580

* fix crash

* Fix tests

* Close conn

* README cleanups

* README

* link RFC
2017-03-13 20:24:37 +00:00
John Belamaric
ef315ef3e2 Rewrite edns0 (#561)
* Add edns0 code rewrite

* check arg count

* change `new`; set EDNS0 if request doesn't have it set

* change set to replace_or_append

* change to append_or_replace

* return error in new

* update documents

* fixt UT

* return error

* go fmt

* Rework for more general EDNS0 use

Also changed how rules are created and validated. Implements
EDNS0 NSID in addition to local.

* go fmt

* README updates, NSID tests and fixes

* gofmt -s -w

* Fix tests for rewrite syntax change

* Add tests, fix error message

* Review nits

* Missed on nit

* More tests, integration test, fix edns0 parse issue

* Fix README, use RewriteIgnored

* go fmt
2017-03-06 21:32:17 +00:00
Miek Gieben
6966bce653 Fix resolving CNAME with no proxy (#564)
This fixes a crash when we resolve (or try to) an external CNAME
when no proxy is set.

Add test as well.
2017-03-02 19:35:44 +00:00
Yong Tang
81af74aad0 Fix import path github.com/miekg/coredns -> github.com/coredns/coredns (#547)
This fix fixes import path from
`github.com/miekg/coredns`
->
`github.com/coredns/coredns`
2017-02-22 06:51:47 +00:00