common

package
v1.29.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2017 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

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

Index

Constants

View Source
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"
)
View Source
const (
	FsMagicAUFS = 0x61756673 // https://goo.gl/CBwx43
	FsMagicZFS  = 0x2FC12FC1 // https://goo.gl/xTvzO5
)
View Source
const (
	RktGroup      = "rkt"       // owns /var/lib/rkt
	RktAdminGroup = "rkt-admin" // owns /etc/rkt
)
View Source
const DefaultPath = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

Variables

This section is empty.

Functions

func AppCreatedPath added in v1.16.0

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 added in v1.29.0

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 added in v0.15.0

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

AppImageManifestPath returns the path to the app's ImageManifest file

func AppInfoPath added in v0.9.0

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

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

func AppPath added in v0.8.0

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 added in v1.16.0

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 added in v1.29.0

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 added in v1.16.0

func AppStatusPath(root, appName string) string

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

func AppStatusPathFromStage1Rootfs added in v1.29.0

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 added in v0.9.0

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

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

func AppsInfoPath added in v0.9.0

func AppsInfoPath(root string) string

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

func AppsPath added in v0.8.0

func AppsPath(root string) string

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

func AppsStatusesPath added in v1.16.0

func AppsStatusesPath(root string) string

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

func AppsStatusesPathFromStage1Rootfs added in v1.29.0

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 added in v1.22.0

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 added in v1.28.0

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 added in v1.22.0

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 added in v1.26.0

func GetArch() string

GetArch returns the current ACI architecture.

func GetExitStatus added in v1.19.0

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 added in v1.26.0

func GetOS() string

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

func GetOSArch added in v1.28.0

func GetOSArch() (os string, arch string)

func GetRktLockFD added in v0.5.1

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 added in v1.29.0

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 added in v1.15.0

func IsDNSZero(dns *cnitypes.DNS) bool
  • TODO(cdc) move this to cnitypes

IsDNSZero checks if the DNS configuration has any information

func IsExperimentEnabled added in v1.19.0

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 added in v0.9.0

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 added in v1.1.0

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 added in v1.15.0

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

MakeResolvConf generates resolv.conf contents given a cni DNS configuration

func MetadataServicePublicURL added in v0.4.0

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

MetadataServicePublicURL returns the public URL used to host the metadata service

func PathSupportsOverlay added in v1.14.0

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 added in v1.21.0

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 added in v1.19.0

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 added in v0.5.1

func PodManifestPath(root string) string

PodManifestPath returns the path in root to the Pod Manifest

func ReadEnvFileRaw added in v1.28.0

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 added in v0.8.0

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 added in v1.12.0

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 added in v0.9.0

func SharedVolumesPath(root string) string

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

func SliceToPath added in v0.6.1

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 added in v0.5.2

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 added in v0.8.0

func SupportsUserNS() bool

SupportsUserNS returns whether the kernel has CONFIG_USER_NS set

func SystemdVersion added in v1.1.0

func SystemdVersion(systemdBinaryPath string) (int, error)

SystemdVersion parses and returns the version of a given systemd binary

func WriteEnvFile added in v1.16.0

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 added in v1.14.0

type ErrOverlayUnsupported string

ErrOverlayUnsupported is the error determining whether OverlayFS is supported.

func (ErrOverlayUnsupported) Error added in v1.14.0

func (e ErrOverlayUnsupported) Error() string

type NetList added in v0.9.0

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 added in v0.9.0

func (l *NetList) All() bool

func (*NetList) Contained added in v0.10.0

func (l *NetList) Contained() bool

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

func (*NetList) Host added in v0.9.0

func (l *NetList) Host() bool

Check if host networking has been requested

func (*NetList) None added in v0.10.0

func (l *NetList) None() bool

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

func (*NetList) Set added in v0.9.0

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

func (*NetList) Specific added in v0.9.0

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

func (*NetList) SpecificArgs added in v0.9.0

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

func (*NetList) String added in v0.9.0

func (l *NetList) String() string

func (*NetList) Strings added in v0.9.0

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

func (*NetList) StringsOnlyNames added in v0.9.0

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

func (*NetList) Type added in v0.9.0

func (l *NetList) Type() string

Directories

Path Synopsis
v1
v2
networking is the package that implements small functionality shared between state0 and stage1.
networking is the package that implements small functionality shared between state0 and stage1.

Jump to

Keyboard shortcuts

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