Commit graph

45 commits

Author SHA1 Message Date
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
87eb0d39a4 Move nonwriter to mw/pkg/nonwriter (#948)
Make it its own package as shared between autopath and federation.

Fixes #933
2017-08-19 17:28:42 +01:00
Miek Gieben
02955d7594 Dns.join (#944)
* Add dnsutil.Join

* Create dnsutil.Join

Create Join helper function and move bits in the code over.
2017-08-19 15:22:09 +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
c0f62e3f65 go lint cleanup (#891)
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-08-10 18:00:23 -07: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
Yong Tang
fefc4374d7 Some go vet cleanup (#869)
Some `go vet` cleanup

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-08-09 11:00:03 -07:00
Yong Tang
a1b175ef78 Move Healthcheck to middleware/pkg/healthcheck (#854)
* Move healthcheck out

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

* Move healthcheck to middleware/pkg/healthcheck

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-08-09 09:21:33 -07:00
Miek Gieben
be551f21a0 core: add missing trimzone files
*ugh*: forgot to add these files. This add the dnsutil.TrimZone
function.
2017-08-08 11:33:51 +00:00
张勋
a04fe81bd8 Change default MaxIdleConnsPerHost of Etcd client’s http.Transport (#853) 2017-08-07 23:27:33 -07:00
Miek Gieben
050eccd69e mw/logs: add rflags to logging (#845)
Add the DNS message response flags as {rflags} to the default logging
Also complete the replacer testing that is was commented out.
And (unrelated) Switch erratic and whoami to ease testing.

Note: {flags} could and should be added as well - but we can leave that
as a beginners bug.
2017-08-07 03:49:40 -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
Yong Tang
7ca018374f golint cleanup (#828)
Clean up some golint related issues.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-08-04 09:46:40 -07:00
Mia Boulay
7fada97ee3 middleware/etcd: move NewHTTPTransport to pkg/tls (#769) 2017-07-01 13:17: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
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
Miek Gieben
64640bd1a0 pkg/debug: Update comment (#704)
We already lowercase before comparing.

Fixes #447
2017-06-03 08:34:42 +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
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
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
Yong Tang
738067a3c7 Fix go fmt, go lint, and go vet issues (#494)
This fix fixes several `go fmt`, `go lint`, and `go vet` issues,
to make goreportcard happy:

https://goreportcard.com/report/github.com/miekg/coredns

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-01-29 20:06:26 +00:00
John Belamaric
2e366459c5 Use common TLS parsing routine for etcd (#476)
* Use common TLS parsing routine for etcd

Change to use the new common routine, and update the docs to reflect
the different options for passing TLS configuration.

* Move middleware/tls to middleware/pkg/tls

This was put in the wrong place originally.
2017-01-12 08:14:24 +00:00
Miek Gieben
c4ab98c6e3 Add middleware.NextOrFailure (#462)
This checks if the next middleware to be called is nil, and if so returns
ServerFailure and an error. This makes the next calling more robust and
saves some lines of code.

Also prefix the error with the name of the middleware to aid in
debugging.
2016-12-20 18:58:05 +00:00
Miek Gieben
b086e5f64d middleware/log: make {size} the length of the request (#449)
* middleware/log: make {size} the length of the request

{size} is the lenght of the request, {rsize} is the length of the
reply.

* Fix test
2016-11-30 20:44:00 +00:00
Miek Gieben
8c8b37a30e middleware/metrics: export actual size (#448)
The `*_size*` metrics now export the actual packet length, not the
advertised one (although that might be nice as well).
2016-11-29 11:02:43 +00:00
Miek Gieben
4cfd19c7c9 middleware/httpproxy: add debug queries (#446)
* middleware/httproxy: implement debug queries

Not too useful at the moment, but o-o.debug queries are supported
and return the Comment from dns.google.com.

Note that this is not always set.

* improve documentation

* Testing cleanups
2016-11-29 09:54:57 +00:00
Miek Gieben
4a8db8a4ce middleware/proxy: config syntax cleanups (#435)
* middleware/proxy: config syntax cleanups

Allow port numbers to be used in the transfer statements and clean
up the proxy stanza parsing. Also allow, when specifying an upstream,
/etc/resolv.conf (or any other file) to be used for getting the upstream
nameserver.

Add tests and fix the documentation to make clear what is allowed.

* Fix the other upstream parse as well
2016-11-24 16:57:20 +01:00
Michael Grosser
ece3cf8ecf Fix various issues with formatting and typos (#424)
* Fix typos

* Simplify code

* Fix error usage
2016-11-13 14:03:12 +00:00
Miek Gieben
e89c4b5c28 middleware/cache: only cache query and responses (#397)
Extent typify to check the transfers, dynamic updates and notifies.
Extend *cache* to not put these in the cache.

Fixes #393
2016-11-07 16:27:50 +00:00
Yong Tang
7843a2bd91 Small golint cleanup. (#338)
A small golint cleanup.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-10-17 16:59:12 -07:00
Miek Gieben
03bc071774 Check for empty message in typify 2016-10-17 10:26:24 +00:00
Miek Gieben
aa7744dc86 cleanups: go vet/golint (#331)
Go vet and golint the new code once again.

Drop Name from NameTemplate - it's cleaner: nametemplate.Template.
2016-10-12 12:46:35 +01:00
Yong Tang
baea5eef2f Add a unit test for DuplicateCNAME (#329)
This fix adds a unit test for DuplicateCNAME to have
a basic coverage for dnsutil.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-10-11 20:25:50 +01:00
Yong Tang
f3066b9463 Add unit tests for ExtractAddressFromReverse (#328)
This fix adds unit tests for `ExtractAddressFromReverse`. It also
updates the implementation of `ExtractAddressFromReverse` so that
only a valid IPv4 or IPv6 address (in string format) is returned.

If the addresses is not valid and can not be handled by golang's
`net.ParseIP` then an empty string (`""`) will be returned.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-10-11 09:48:15 +01:00
Miek Gieben
c22b7b2252 middleware/log: allows logging based on response classes (#325)
Add the ability to add a class of responses to be logged; success,
denial or error. The default is to log everything (all).

Fixes #258
2016-10-10 12:09:29 +01:00
Miek Gieben
e8b4412564 tests: clean up output
Some document improvements and add a few more tests.
2016-10-08 16:44:43 +01:00
Miek Gieben
e54c232c8c middleware/cache: split cache in positive and negative and use lru (#298)
Make the cache memory bounded, by using a LRU cache. Also split the
cache in a positive and negative one - each with its own controls.

Extend the cache stanza to allow for this:

    cache {
       positive limit [ttl]
       negative limit [ttl]
    }

is now possible. This also add a cache_test.go in the toplevel test/
directory that exercises the caching path.

Fixes #260
2016-10-02 08:31:44 +01:00
Miek Gieben
de0fa53379 Doc: add package docs (#296)
* Doc: add package docs

Add short package level docs to make godoc looks nicer.
Add some badges to the README.

* correct url
2016-09-25 08:39:20 +01:00
Manuel de Brito Fontes
8e6257c51f Lister refactor kubernetes/kubernetes#33269 2016-09-23 10:23:11 -03:00
Manuel de Brito Fontes
2b62384223 Refactoring of k8s helpers 2016-09-23 09:48:11 -03:00
Miek Gieben
090d1872e9 Golint2 (#280)
* Fix linter errors

* More linting fixes

* More docs and making members private that dont need to be public

* Fix linter errors

* More linting fixes

* More docs and making members private that dont need to be public

* More lint fixes

This leaves:

~~~
middleware/kubernetes/nametemplate/nametemplate.go:64:6: exported type NameTemplate should have comment or be unexported
middleware/kubernetes/nametemplate/nametemplate.go:71:1: exported method NameTemplate.SetTemplate should have comment or be unexported
middleware/kubernetes/nametemplate/nametemplate.go:108:1: exported method NameTemplate.GetZoneFromSegmentArray should have comment or be unexported
middleware/kubernetes/nametemplate/nametemplate.go:116:1: exported method NameTemplate.GetNamespaceFromSegmentArray should have comment or be unexported
middleware/kubernetes/nametemplate/nametemplate.go:120:1: exported method NameTemplate.GetServiceFromSegmentArray should have comment or be unexported
middleware/kubernetes/nametemplate/nametemplate.go:124:1: exported method NameTemplate.GetTypeFromSegmentArray should have comment or be unexported
middleware/kubernetes/nametemplate/nametemplate.go:135:1: exported method NameTemplate.GetSymbolFromSegmentArray should have comment or be unexported
middleware/kubernetes/nametemplate/nametemplate.go:167:1: exported method NameTemplate.IsValid should have comment or be unexported
middleware/kubernetes/nametemplate/nametemplate.go:182:6: exported type NameValues should have comment or be unexported
middleware/kubernetes/util/util.go:1:1: package comment should be of the form "Package util ..."
middleware/kubernetes/util/util.go:27:2: exported const WildcardStar should have comment (or a comment on this block) or be unexported
middleware/proxy/lookup.go:66:1: exported method Proxy.Forward should have comment or be unexported
middleware/proxy/proxy.go:24:6: exported type Client should have comment or be unexported
middleware/proxy/proxy.go:107:1: exported function Clients should have comment or be unexported
middleware/proxy/reverseproxy.go:10:6: exported type ReverseProxy should have comment or be unexported
middleware/proxy/reverseproxy.go:16:1: exported method ReverseProxy.ServeDNS should have comment or be unexported
middleware/proxy/upstream.go:42:6: exported type Options should have comment or be unexported
~~~

I plan on reworking the proxy anyway, so I'll leave that be.
2016-09-23 09:14:12 +01:00
Miek Gieben
5301c5af5f Run golint and go vet (#276)
Cleanup the errors and removed deadcode along the way. The leaves
some error laying around, mostly about commenting exported identifier.
We should look hard if those really are needed.
2016-09-21 17:01:19 +01:00
Yong Tang
953cfc1de4 Remove lumberjack logger (#257)
* Removed lumberjack from coremain

As is mentioned in 251, this fix removed lumberjack from coremain.

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

* Remove lumberjack from log middleware

As mentioned in 251, lumberjack is not suitable for applications like CoreDNS
so it is removed from the log middleware.

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

* Update log/README.md as lumberjack has been removed

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

* Adjust default log output from `ioutil.Discard` to `os.Stdout`

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-09-16 15:50:16 +01:00
Miek Gieben
d1f17fa7e0 Cleanup: put middleware helper functions in pkgs (#245)
Move all (almost all) Go files in middleware into their
own packages. This makes for better naming and discoverability.

Lot of changes elsewhere to make this change.

The middleware.State was renamed to request.Request which is better,
but still does not cover all use-cases. It was also moved out middleware
because it is used by `dnsserver` as well.

A pkg/dnsutil packages was added for shared, handy, dns util functions.

All normalize functions are now put in normalize.go
2016-09-07 11:10:16 +01:00