rescontainer

package
v3.0.0-rc67 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 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 (
	// 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.

View Source
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"),
	}
	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"),
	}
)
View Source
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.

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