rescontainer

package
v3.0.0-rc55 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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

View Source
var (
	KWPromoteRW = keywords.Keyword{
		Attr:      "PromoteRW",
		Converter: converters.Bool,
		Option:    "promote_rw",
		Scopable:  true,
		Text:      keywords.NewText(fs, "text/kw/promote_rw"),
	}
	KWOsvcRootPath = keywords.Keyword{
		Attr:     "OsvcRootPath",
		Example:  "/opt/opensvc",
		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",
		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 -- ",
		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",
		Option:       "name",
		Required:     true,
		Scopable:     true,
		StopToChange: true,
		Text:         keywords.NewText(fs, "text/kw/name"),
	}
	KWHostname = keywords.Keyword{
		Attr:     "Hostname",
		Example:  "nginx1",
		Option:   "hostname",
		Scopable: true,
		Text:     keywords.NewText(fs, "text/kw/hostname"),
	}
	KWStartTimeout = keywords.Keyword{
		Attr:      "StartTimeout",
		Converter: converters.Duration,
		Default:   "4m",
		Example:   "1m5s",
		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",
		Option:    "stop_timeout",
		Scopable:  true,
		Text:      keywords.NewText(fs, "text/kw/stop_timeout"),
	}
)
View Source
var ResolvConfOptions = []string{"ndots:2", "edns0", "use-vc"}

ResolvConfOptions are the resolver options a container is given, the same ones the "--dns-opt" arguments used to carry.

Functions

func Nameservers

func Nameservers(cluster, extra []string) []string

Nameservers returns the nameservers of a container: the ones of the cluster, 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.

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

func ProvisionStarts(ctx context.Context, standby bool) bool

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

func SearchDomains(objectDomain string, extra []string) []string

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 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

type NetNSAddresser interface {
	RID() string
	NetNSResource() string
	NetworkNameservers() []string
}

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) String

func (t ResolvConf) String() string

String returns the file content.

Jump to

Keyboard shortcuts

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