Documentation
¶
Index ¶
- Constants
- Variables
- func Nameservers(cluster, extra []string) []string
- func NetworkNameservers(netns string, addrs []NetNSAddresser) []string
- func ProvisionStarts(ctx context.Context, standby bool) bool
- func SearchDomains(objectDomain string, extra []string) []string
- func ShutdownWait(ctx context.Context, stopTimeout time.Duration) time.Duration
- func WriteResolvConf(path string, resolvConf ResolvConf) (string, error)
- type NetNSAddresser
- type ResolvConf
Constants ¶
const MaxNameservers = 3
MaxNameservers is the number of nameservers a resolver reads. glibc and musl both stop at MAXNS, and the lines past it are dead weight in the file.
The search list is not capped the same way: the implementations disagree on its limit, glibc counting domains and musl counting bytes, so the file says what was asked and each resolver applies its own rule.
Variables ¶
var ( // GroupIdentity holds the name of the container and its hostname. GroupIdentity = keywords.Group{ ID: "identity", Name: "Identity", Text: keywords.NewText(fs, "text/group/identity"), Order: 10, } // GroupMachine holds the virtual hardware of a virtual machine. GroupMachine = keywords.Group{ ID: "machine", Name: "Virtual machine", Text: keywords.NewText(fs, "text/group/machine"), Order: 20, } // GroupStorage holds where the container keeps its files, and the // storage of the node it uses. GroupStorage = keywords.Group{ ID: "storage", Name: "Storage", Text: keywords.NewText(fs, "text/group/storage"), Order: 50, } // GroupNetwork holds the networks the container is on, and its // resolver. GroupNetwork = keywords.Group{ ID: "network", Name: "Network", Text: keywords.NewText(fs, "text/group/network"), Order: 60, } // GroupGuest holds how the agent of the node reaches the system in the // container, and the agent running there, for the encapsulated // resources and the commands run in the container. GroupGuest = keywords.Group{ ID: "guest", Name: "Guest", Text: keywords.NewText(fs, "text/group/guest"), Order: 80, } // GroupTimeouts holds how long the actions on the container may take. GroupTimeouts = keywords.Group{ ID: "timeouts", Name: "Timeouts", Text: keywords.NewText(fs, "text/group/timeouts"), Order: 90, } )
The groups of the keywords several container drivers have, declared once here and added by each driver whose keywords name them. A group holds, in a driver, the keywords that driver declares with its id: the network of an oci container is its netns and its resolver, the one of a kvm guest its bridges and om networks.
The drivers add their own groups, as the image of an oci container, in the order between these.
var ( KWPromoteRW = keywords.Keyword{ Attr: "PromoteRW", Converter: converters.Bool, Deprecated: "v3.0.0-rc62", Group: GroupStorage.ID, Option: "promote_rw", Scopable: true, Text: keywords.NewText(fs, "text/kw/promote_rw"), } KWOsvcRootPath = keywords.Keyword{ Attr: "OsvcRootPath", Example: "/opt/opensvc", Group: GroupGuest.ID, Option: "osvc_root_path", Scopable: true, Text: keywords.NewText(fs, "text/kw/osvc_root_path"), } KWGuestOS = keywords.Keyword{ Aliases: []string{"guestos"}, Attr: "GuestOS", Candidates: []string{"unix", "windows"}, Default: "unix", Example: "unix", Group: GroupGuest.ID, Option: "guest_os", Scopable: true, Text: keywords.NewText(fs, "text/kw/guest_os"), } KWRCmd = keywords.Keyword{ Attr: "RCmd", Converter: converters.Shlex, Example: "lxc-attach -e -n osvtavnprov01 -- ", Group: GroupGuest.ID, Option: "rcmd", Scopable: true, Text: keywords.NewText(fs, "text/kw/rcmd"), Default: "/usr/bin/ssh -o StrictHostKeyChecking=accept-new -o ForwardX11=no", } KWName = keywords.Keyword{ Attr: "Name", Group: GroupIdentity.ID, Option: "name", Required: true, Scopable: true, StopToChange: true, Text: keywords.NewText(fs, "text/kw/name"), } KWHostname = keywords.Keyword{ Attr: "Hostname", Example: "nginx1", Group: GroupIdentity.ID, Option: "hostname", Scopable: true, Text: keywords.NewText(fs, "text/kw/hostname"), Validate: dnsname.CheckHostname, } KWStartTimeout = keywords.Keyword{ Attr: "StartTimeout", Converter: converters.Duration, Default: "4m", Example: "1m5s", Group: GroupTimeouts.ID, Option: "start_timeout", Scopable: true, Text: keywords.NewText(fs, "text/kw/start_timeout"), } KWStopTimeout = keywords.Keyword{ Attr: "StopTimeout", Converter: converters.Duration, Default: "2m", Example: "2m30s", Group: GroupTimeouts.ID, Option: "stop_timeout", Scopable: true, Text: keywords.NewText(fs, "text/kw/stop_timeout"), } )
var ResolvConfOptions = []string{"ndots:2", "edns0", "timeout:2", "attempts:2"}
ResolvConfOptions are the resolver options a container is given.
The queries go over udp, edns0 allowing large answers, and a truncated one is asked again over tcp by the resolver itself. A nameserver whose process is down answers udp with a port unreachable, so the next one is asked at once, and a nameserver whose node is down costs the timeout. use-vc, which forced tcp, made the latter wait for the connection to give up, the syn retried for over a minute, glibc applying no timeout to the connect.
The timeout is the wait for a nameserver with glibc, and for the whole lookup with musl, which asks all the nameservers at once: 1s would fail a recursion slower than that, a cold one to an external domain.
var StopKillMargin = 5 * time.Second
StopKillMargin is what a stop leaves, of the time of its action, to the forced stop of a container its shutdown did not stop, as the lxc driver leaves its kill: the wait for the shutdown ending with the deadline of the action, the forced stop ran out of time, and the container stayed up. Replaced by the tests.
Functions ¶
func Nameservers ¶
Nameservers returns the nameservers of a container: the ones of the cluster, the one the node runs first, then the extra ones its configuration adds.
The order is not a preference, it is what makes both work. A resolver tries the nameservers in order and moves to the next only when one does not answer: a name it is told does not exist is an answer. So a nameserver that does not serve the cluster zone, asked first, would answer NXDOMAIN for every object of the cluster and the search would stop there.
The nameserver of the node, an address of cluster.dns an interface of the host holds, comes first: the record of an instance started on the node is the one it answers first, which wait_dns waits for, and it is among the ones a resolver reads, however many cluster.dns lists.
func NetworkNameservers ¶
func NetworkNameservers(netns string, addrs []NetNSAddresser) []string
NetworkNameservers returns the nameservers of the networks the addresses of a network namespace are on, the ones of each address in turn, once: the nameservers of the cluster may not be reachable from them.
func ProvisionStarts ¶
ProvisionStarts says whether the provision of a container starts it: on the placement leader, and on every node for a standby resource.
Off the leader, the provision of an instance stops what it started, the leader starting the instance. A container started there for that while needs what it mounts, which the resources the leader alone starts hold, as the shared vol a volume_mounts names: the path is not there, and the start fails the provision of the node. Starting it serves nothing either: the image is pulled at the first start, wherever the instance is placed then.
func SearchDomains ¶
SearchDomains returns the search list of an object, which is its domain and each of the parents of that domain.
The domain of "root/svc/svc1" in cluster "clu" is "root.svc.clu", so a name is looked up in the namespace of the object, then in its kind, then in the cluster. The extra domains come first, so a configured one wins.
func ShutdownWait ¶
ShutdownWait returns how long a stop waits for a container to shut down before forcing it: its stop_timeout, shortened to leave StopKillMargin before the deadline of ctx, the one of the action, which the stop_timeout of the object sets. Zero when there is no time left for a wait: the stop then forces the container at once.
func WriteResolvConf ¶
func WriteResolvConf(path string, resolvConf ResolvConf) (string, error)
WriteResolvConf writes the resolver configuration to path and returns it.
The file is written where a container mounts it from, and the container reads it for as long as it runs: a container adapts to a cluster layout change by being restarted, which is when this is written again.
Types ¶
type NetNSAddresser ¶
NetNSAddresser is implemented by the ip resources configuring an address in the network namespace of a container: the resource whose namespace it is, and the nameservers reachable from the network the address is on, none when the network names none.
type ResolvConf ¶
type ResolvConf struct {
// Nameservers are written one "nameserver" line each, in order.
Nameservers []string
// Searches are written as the single "search" line, in order.
Searches []string
// Options are written as the single "options" line, in order.
Options []string
}
ResolvConf is the resolver configuration handed to a container.
func (ResolvConf) IsZero ¶
func (t ResolvConf) IsZero() bool
IsZero returns true when the resolver configuration names no nameserver, and the container is better left with the resolver its engine gives it.
A search list alone is no resolver: the domains of an object are the ones the cluster dns serves, so without a nameserver they name nothing, and a file holding them alone leaves the container resolving no name at all, where the engine would have given it the nameservers of the host.
func (ResolvConf) WrittenNameservers ¶
func (t ResolvConf) WrittenNameservers() []string
WrittenNameservers returns the nameservers the file holds: the first ones named, as many as a resolver reads.