package common

import "github.com/coreos/rkt/common"

Package common defines values shared by different parts of rkt (e.g. stage0 and stage1)

Index

Constants

const (
	SharedVolumePerm = os.FileMode(0755)

	AppsInfoDir = "/appsinfo"

	EnvLockFd                    = "RKT_LOCK_FD"
	EnvSELinuxContext            = "RKT_SELINUX_CONTEXT"
	EnvSELinuxMountContext       = "RKT_SELINUX_MOUNT_CONTEXT"
	Stage1TreeStoreIDFilename    = "stage1TreeStoreID"
	AppTreeStoreIDFilename       = "treeStoreID"
	OverlayPreparedFilename      = "overlay-prepared"
	PrivateUsersPreparedFilename = "private-users-prepared"

	PrepareLock = "prepareLock"

	MetadataServicePort    = 18112
	MetadataServiceRegSock = "/run/rkt/metadata-svc.sock"

	APIServiceListenAddr = "localhost:15441"

	DefaultLocalConfigDir  = "/etc/rkt"
	DefaultSystemConfigDir = "/usr/lib/rkt"

	// Default perm bits for the regular files
	// within the stage1 directory. (e.g. image manifest,
	// pod manifest, stage1ID, etc).
	DefaultRegularFilePerm = os.FileMode(0640)

	// Default perm bits for the regular directories
	// within the stage1 directory.
	DefaultRegularDirPerm = os.FileMode(0750)

	// Enter command for crossing entrypoints.
	CrossingEnterCmd = "RKT_STAGE1_ENTERCMD"
	// Stage1 (PID) to enter, used by crossing entrypoints.
	CrossingEnterPID = "RKT_STAGE1_ENTERPID"
	// Stage2 (application name) to enter, optionally used by crossing entrypoints.
	CrossingEnterApp = "RKT_STAGE1_ENTERAPP"
)
const (
	FsMagicAUFS = 0x61756673 // https://goo.gl/CBwx43
	FsMagicZFS  = 0x2FC12FC1 // https://goo.gl/xTvzO5
)
const (
	RktGroup      = "rkt"       // owns /var/lib/rkt
	RktAdminGroup = "rkt-admin" // owns /etc/rkt
)
const DefaultPath = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

Functions

func AppCreatedPath

func AppCreatedPath(root, appName string) string

AppCreatedPath returns the path of the ${appname}-created file, which is used to record the creation timestamp of the app.

func AppCreatedPathFromStage1Rootfs

func AppCreatedPathFromStage1Rootfs(rootfs, appName string) string

AppCreatedPathFromStage1Rootfs returns the path of the ${appname}-created file, which is used to record the creation timestamp of the app. It receives the stage1 rootfs as parameter instead of the pod root.

func AppImageManifestPath

func AppImageManifestPath(root string, appName types.ACName) string

AppImageManifestPath returns the path to the app's ImageManifest file

func AppInfoPath

func AppInfoPath(root string, appName types.ACName) string

AppInfoPath returns the path to the app's appsinfo directory of a pod.

func AppPath

func AppPath(root string, appName types.ACName) string

AppPath returns the path to an app's rootfs.

func AppRootfsPath

func AppRootfsPath(root string, appName types.ACName) string

AppRootfsPath returns the path to an app's rootfs.

func AppStartedPath

func AppStartedPath(root, appName string) string

AppStartedPath returns the path of the ${appname}-started file, which is used to record the start timestamp of the app.

func AppStartedPathFromStage1Rootfs

func AppStartedPathFromStage1Rootfs(rootfs, appName string) string

AppStartedPathFromStage1Rootfs returns the path of the ${appname}-started file, which is used to record the start timestamp of the app. It receives the stage1 rootfs as parameter instead of the pod root.

func AppStatusPath

func AppStatusPath(root, appName string) string

AppStatusPath returns the path of the status file of an app.

func AppStatusPathFromStage1Rootfs

func AppStatusPathFromStage1Rootfs(rootfs, appName string) string

AppStatusPathFromStage1Rootfs returns the path of the status file of an app. It receives the stage1 rootfs as parameter instead of the pod root.

func AppTreeStoreIDPath

func AppTreeStoreIDPath(root string, appName types.ACName) string

AppTreeStoreIDPath returns the path to the app's treeStoreID file of a pod.

func AppsInfoPath

func AppsInfoPath(root string) string

AppsInfoPath returns the path to the appsinfo directory of a pod.

func AppsPath

func AppsPath(root string) string

AppsPath returns the path where the apps within a pod live.

func AppsStatusesPath

func AppsStatusesPath(root string) string

AppsStatusesPath returns the path of the status dir for all apps.

func AppsStatusesPathFromStage1Rootfs

func AppsStatusesPathFromStage1Rootfs(rootfs string) string

AppsStatusesPathFromStage1Rootfs returns the path of the status dir for all apps. It receives the stage1 rootfs as parameter instead of the pod root.

func ChrootPrivateUnmount

func ChrootPrivateUnmount(targetPath string, log *rktlog.Logger, diagf func(string, ...interface{})) error

ChrootPrivateUnmount cleans up in a safe way all mountpoints existing under `targetPath`. This requires multiple steps:

  1. take handles to the current rootdir and workdir (to restore at the end)
  2. parse /proc/self/mountinfo to get a list of all mount targets, and filter out those outside of targetPath
  3. chroot into target path, so that all mounts and symlinks can be properly de-referenced as they appear inside the rootfs
  4. mark all mounts as private, so that further operations are not propagated outside of this rootfs - in descending nest order (parent first)
  5. unmount all mount targets - in ascending nest order (children first). If unmount fails, lazy-detach the mount target so that the kernel can still clean it up once it ceases to be busy
  6. chdir and chroot back to the original state

func ComposeEnviron

func ComposeEnviron(env types.Environment) []string

ComposeEnviron formats the environment into a slice of strings, each of the form "key=value". The minimum required environment variables by the appc spec will be set to sensible defaults here if they're not provided by env.

func CreateSharedVolumesPath

func CreateSharedVolumesPath(root string) (string, error)

CreateSharedVolumesPath ensures the sharedVolumePath for the pod root passed in exists. It returns the shared volume path or an error.

func GetArch

func GetArch() string

GetArch returns the current ACI architecture.

func GetExitStatus

func GetExitStatus(err error) (int, error)

GetExitStatus converts an error to an exit status. If it wasn't an exit status != 0 it returns the same error that it was called with

func GetOS

func GetOS() string

GetOS returns the current ACI operating system (linux, windows etc...)

func GetOSArch

func GetOSArch() (os string, arch string)

func GetRktLockFD

func GetRktLockFD() (int, error)

func ImageManifestPath

func ImageManifestPath(root string, appName types.ACName) string

ImageManifestPath returns the path to the app's manifest file of a pod.

func ImageNameToAppName

func ImageNameToAppName(name types.ACIdentifier) (*types.ACName, error)

ImageNameToAppName converts the full name of image to an app name without special characters - we use it as a default app name when specyfing it is optional

func IsDNSZero

func IsDNSZero(dns *cnitypes.DNS) bool

IsDNSZero checks if the DNS configuration has any information

func IsExperimentEnabled

func IsExperimentEnabled(name string) bool

IsExperimentEnabled returns true if the given rkt experiment is enabled. The given name is converted to upper case and a bool RKT_EXPERIMENT_{NAME} environment variable is retrieved. If the experiment name is unknown, false is returned. If the environment variable does not contain a valid bool value according to strconv.ParseBool, false is returned.

func LookupGid

func LookupGid(groupName string) (gid int, err error)

LookupGid reads the group file and returns the gid of the group specified by groupName.

func LookupPath

func LookupPath(bin string, paths string) (string, error)

LookupPath search for bin in paths. If found, it returns its absolute path, if not, an error

func MakeResolvConf

func MakeResolvConf(dns cnitypes.DNS, comment string) string

MakeResolvConf generates resolv.conf contents given a cni DNS configuration

func MetadataServicePublicURL

func MetadataServicePublicURL(ip net.IP, token string) string

MetadataServicePublicURL returns the public URL used to host the metadata service

func PathSupportsOverlay

func PathSupportsOverlay(path string) error

PathSupportsOverlay checks whether the given path is compatible with OverlayFS. This method also calls SupportsOverlay().

It returns an instance of ErrOverlayUnsupported if OverlayFS is not supported or any other error if determining overlay support failed.

func PodCreatedPath

func PodCreatedPath(root string) string

PodCreatedPath returns the path in root to the Pod Created file used to denote the time of creation.

func PodManifestLockPath

func PodManifestLockPath(root string) string

PodManifestLockPath returns the path in root to the Pod Manifest lock file. This must be different from the PodManifestPath since mutations on the pod manifest file happen by overwriting the original file.

func PodManifestPath

func PodManifestPath(root string) string

PodManifestPath returns the path in root to the Pod Manifest

func ReadEnvFileRaw

func ReadEnvFileRaw(envFilePath string) ([]string, error)

ReadEnvFileRaw reads the environment file, returning it as a slice of strings, each expected but not checked to be of the form "key=value". (The suffix leaves room for a function which parallels WriteEnvFile, which splits each string and has a return type of types.Environment.)

func RelAppPath

func RelAppPath(appName types.ACName) string

RelAppPath returns the path of an app relative to the stage1 chroot.

func RelAppRootfsPath

func RelAppRootfsPath(appName types.ACName) string

RelAppRootfsPath returns the path of an app's rootfs relative to the stage1 chroot.

func RemoveEmptyLines

func RemoveEmptyLines(str string) []string

RemoveEmptyLines removes empty lines from the given string and breaks it up into a list of strings at newline characters

func SharedVolumesPath

func SharedVolumesPath(root string) string

SharedVolumesPath returns the path to the shared (empty) volumes of a pod.

func SliceToPath

func SliceToPath(unit string) (string, error)

SliceToPath explodes a slice name to its corresponding path in the cgroup hierarchy. For example, a slice named "foo-bar-baz.slice" corresponds to the path "foo.slice/foo-bar.slice/foo-bar-baz.slice". See systemd.slice(5)

func Stage1ImagePath

func Stage1ImagePath(root string) string

Stage1ImagePath returns the path where the stage1 app image (unpacked ACI) is rooted, (i.e. where its contents are extracted during stage0).

func Stage1ManifestPath

func Stage1ManifestPath(root string) string

Stage1ManifestPath returns the path to the stage1's manifest file inside the expanded ACI.

func Stage1RootfsPath

func Stage1RootfsPath(root string) string

Stage1RootfsPath returns the path to the stage1 rootfs

func SupportsOverlay

func SupportsOverlay() error

SupportsOverlay returns whether the operating system generally supports OverlayFS, returning an instance of ErrOverlayUnsupported which encodes the reason. It is sufficient to check for nil if the reason is not of interest.

func SupportsUserNS

func SupportsUserNS() bool

SupportsUserNS returns whether the kernel has CONFIG_USER_NS set

func SystemdVersion

func SystemdVersion(systemdBinaryPath string) (int, error)

SystemdVersion parses and returns the version of a given systemd binary

func WriteEnvFile

func WriteEnvFile(env []string, uidRange *user.UidRange, envFilePath string) error

WriteEnvFile creates an environment file for given app name. To ensure the minimum required environment variables by the appc spec are set to sensible defaults, env should be the result of calling ComposeEnviron. The containing directory and its ancestors will be created if necessary.

Types

type ErrOverlayUnsupported

type ErrOverlayUnsupported string

ErrOverlayUnsupported is the error determining whether OverlayFS is supported.

func (ErrOverlayUnsupported) Error

func (e ErrOverlayUnsupported) Error() string

type NetList

type NetList struct {
	// contains filtered or unexported fields
}

NetList implements the flag.Value interface to allow specification of --net with and without values Example: --net="all,net1:k1=v1;k2=v2,net2:l1=w1"

func (*NetList) All

func (l *NetList) All() bool

func (*NetList) Contained

func (l *NetList) Contained() bool

Check if the container needs to be put in a separate network namespace

func (*NetList) Host

func (l *NetList) Host() bool

Check if host networking has been requested

func (*NetList) None

func (l *NetList) None() bool

Check if 'none' (loopback only) networking has been requested

func (*NetList) Set

func (l *NetList) Set(value string) error

func (*NetList) Specific

func (l *NetList) Specific(net string) bool

func (*NetList) SpecificArgs

func (l *NetList) SpecificArgs(net string) string

func (*NetList) String

func (l *NetList) String() string

func (*NetList) Strings

func (l *NetList) Strings() []string

func (*NetList) StringsOnlyNames

func (l *NetList) StringsOnlyNames() (list []string)

func (*NetList) Type

func (l *NetList) Type() string

Source Files

cgroup_util.go common.go environment.go experiment.go group.go mount.go resolv_conf.go

Directories

PathSynopsis
common/apps
common/cgroup
common/cgroup/v1
common/cgroup/v2
common/labelsort
common/networkingnetworking is the package that implements small functionality shared between state0 and stage1.
common/overlay
Version
v1.30.0 (latest)
Published
Apr 13, 2018
Platform
linux/amd64
Imports
25 packages
Last checked
5 days ago

Tools for package owners.