autopath

package
v1.8.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 9, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

README

autopath

Name

autopath - allows for server-side search path completion.

Description

If the autopath plugin sees a query that matches the first element of the configured search path, it will follow the chain of search path elements and return the first reply that is not NXDOMAIN. On any failures, the original reply is returned. Because autopath returns a reply for a name that wasn't the original question, it will add a CNAME that points from the original name (with the search path element in it) to the name of this answer.

Note: There are several known issues, see the "Bugs" section below.

Syntax

autopath [ZONE...] RESOLV-CONF
  • ZONES zones autopath should be authoritative for.
  • RESOLV-CONF points to a resolv.conf like file or uses a special syntax to point to another plugin. For instance @kubernetes, will call out to the kubernetes plugin (for each query) to retrieve the search list it should use.

If a plugin implements the AutoPather interface then it can be used by autopath.

Metrics

If monitoring is enabled (via the prometheus plugin) then the following metric is exported:

  • coredns_autopath_success_total{server} - counter of successfully autopath-ed queries.

The server label is explained in the metrics plugin documentation.

Examples

autopath my-resolv.conf

Use my-resolv.conf as the file to get the search path from. This file only needs to have one line: search domain1 domain2 ...

autopath @kubernetes

Use the search path dynamically retrieved from the kubernetes plugin.

Bugs

In Kubernetes, autopath can derive the wrong namespace of a client Pod (and therefore wrong search path) in the following case. To properly build the search path of a client autopath needs to know the namespace of the a Pod making a DNS request. To do this, it relies on the kubernetes plugin's Pod cache to resolve the client's IP address to a Pod. The Pod cache is maintained by an API watch on Pods. When Pod IP assignments change, the Kubernetes API notifies CoreDNS via the API watch. However, that notification is not instantaneous. In the case that a Pod is deleted, and it's IP is immediately provisioned to a Pod in another namespace, and that new Pod make a DNS lookup before the API watch can notify CoreDNS of the change, autopath will resolve the IP to the previous Pod's namespace.

In Kubernetes, autopath is not compatible with Pods running from Windows nodes.

If the server side search ultimately results in a negative answer (e.g. NXDOMAIN), then the client will fruitlessly search all paths manually, thus negating the autopath optimization.

Documentation

Overview

Package autopath implements autopathing. This is a hack; it shortcuts the client's search path resolution by performing these lookups on the server...

The server has a copy (via AutoPathFunc) of the client's search path and on receiving a query it first establishes if the suffix matches the FIRST configured element. If no match can be found the query will be forwarded up the plugin chain without interference (if, and only if, 'fallthrough' has been set).

If the query is deemed to fall in the search path the server will perform the queries with each element of the search path appended in sequence until a non-NXDOMAIN answer has been found. That reply will then be returned to the client - with some CNAME hackery to let the client accept the reply.

If all queries return NXDOMAIN we return the original as-is and let the client continue searching. The client will go to the next element in the search path, but we won’t do any more autopathing. It means that in the failure case, you do more work, since the server looks it up, then the client still needs to go through the search path.

It is assume the search path ordering is identical between server and client.

Plugins implementing autopath, must have a function called `AutoPath` of type autopath.Func. Note the searchpath must be ending with the empty string.

I.e:

func (m Plugins ) AutoPath(state request.Request) []string {
	return []string{"first", "second", "last", ""}
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoPath

type AutoPath struct {
	Next  plugin.Handler
	Zones []string
	// contains filtered or unexported fields
}

AutoPath performs autopath: service side search path completion.

func (*AutoPath) Name

func (a *AutoPath) Name() string

Name implements the Handler interface.

func (*AutoPath) ServeDNS

func (a *AutoPath) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

ServeDNS implements the plugin.Handle interface.

type AutoPather added in v1.0.2

type AutoPather interface {
	AutoPath(request.Request) []string
}

AutoPather defines the interface that a plugin should implement in order to be used by AutoPath.

type Func

type Func func(request.Request) []string

Func defines the function plugin should implement to return a search path to the autopath plugin. The last element of the slice must be the empty string. If Func returns a nil slice, no autopathing will be done.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL