common

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2016 License: Apache-2.0, MIT Imports: 21 Imported by: 0

Documentation

Overview

Package common and the file kvm_mount.go provide functions for creating mount units for managing inner(kind=empty) and external(kind=host) volumes. note: used only for kvm flavor (lkvm based)

Idea. For example when we have two volumes: 1) --volume=hostdata,kind=host,source=/host/some_data_to_share 2) --volume=temporary,kind=empty then in stage1/rootfs rkt creates two folders (in rootfs of guest)

  1. /mnt/hostdata - which is mounted through 9p host thanks to lkvm --9p=/host/some_data_to_share,hostdata flag shared to quest
  2. /mnt/temporary - is created as empty directory in guest

both of them are then bind mounted to /opt/stage2/<application/<mountPoint.path> for every application, that has mountPoints specified in ACI json

  • host mounting is realized by podToSystemdHostMountUnits (for whole pod), which creates mount.units (9p) required and ordered before all applications service units
  • bind mounting is realized by appToSystemdMountUnits (for each app), which creates mount.units (bind) required and ordered before particular application

note: systemd mount units require /usr/bin/mount

Index

Constants

View Source
const (
	// FlavorFile names the file storing the pod's flavor
	FlavorFile = "flavor"
)
View Source
const (
	// UnitsDir is the default path to systemd systemd unit directory
	UnitsDir = "/usr/lib/systemd/system"
)

Variables

This section is empty.

Functions

func AppToSystemdMountUnits added in v0.14.0

func AppToSystemdMountUnits(root string, appName types.ACName, volumes []types.Volume, ra *schema.RuntimeApp, unitsDir string) error

AppToSystemdMountUnits prepare bind mount unit for empty or host kind mounting between stage1 rootfs and chrooted filesystem for application

func EnvFilePath added in v0.14.0

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

EnvFilePath returns the path to the environment file for the given app name.

func GenerateMounts

func GenerateMounts(ra *schema.RuntimeApp, volumes map[types.ACName]types.Volume) []schema.Mount

GenerateMounts maps MountPoint paths to volumes, returning a list of Mounts.

func GetAppHashes added in v0.14.0

func GetAppHashes(p *stage1commontypes.Pod) []types.Hash

GetAppHashes returns a list of hashes of the apps in this pod

func GetFlavor added in v0.14.0

func GetFlavor(p *stage1commontypes.Pod) (flavor string, systemdVersion string, err error)

GetFlavor populates a flavor string based on the flavor itself and respectively the systemd version

func GetMachineID added in v0.14.0

func GetMachineID(p *stage1commontypes.Pod) string

GetMachineID returns the machine id string of the pod to be passed to systemd-nspawn

func InitDebug added in v1.0.0

func InitDebug(debug bool)

func InstantiatedPrepareAppUnitName added in v0.14.0

func InstantiatedPrepareAppUnitName(appName types.ACName) string

InstantiatedPrepareAppUnitName returns the systemd service unit name for prepare-app instantiated for the given root.

func IsMountReadOnly

func IsMountReadOnly(vol types.Volume, mountPoints []types.MountPoint) bool

IsMountReadOnly returns if a mount should be readOnly. If the readOnly flag in the pod manifest is not nil, it overrides the readOnly flag in the image manifest.

func PodToNspawnArgs added in v0.14.0

func PodToNspawnArgs(p *stage1commontypes.Pod) ([]string, error)

PodToNspawnArgs renders a prepared Pod as a systemd-nspawn argument list ready to be executed

func PodToSystemd added in v0.14.0

func PodToSystemd(p *stage1commontypes.Pod, interactive bool, flavor string, privateUsers string) error

PodToSystemd creates the appropriate systemd service unit files for all the constituent apps of the Pod

func PodToSystemdHostMountUnits added in v0.14.0

func PodToSystemdHostMountUnits(root string, volumes []types.Volume, appNames []types.ACName, unitsDir string) error

PodToSystemdHostMountUnits create host shared remote file system mounts (using e.g. 9p) according to https://www.kernel.org/doc/Documentation/filesystems/9p.txt. Additionally it creates required directories in stage1MntDir and then prepares bind mount unit for each app. "root" parameter is stage1 root filesystem path. appNames are used to create before/required dependency between mount unit and app service units.

func RelEnvFilePath added in v0.14.0

func RelEnvFilePath(appName types.ACName) string

RelEnvFilePath returns the path to the environment file for the given app name relative to the pod's root.

func ServiceUnitName added in v0.14.0

func ServiceUnitName(appName types.ACName) string

ServiceUnitName returns a systemd service unit name for the given app name.

func ServiceUnitPath added in v0.14.0

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

ServiceUnitPath returns the path to the systemd service file for the given app name.

func ServiceWantPath added in v0.14.0

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

ServiceWantPath returns the systemd default.target want symlink path for the given app name.

func SetJournalPermissions added in v0.15.0

func SetJournalPermissions(p *stage1commontypes.Pod) error

SetJournalPermissions sets ACLs and permissions so the rkt group can access the pod's logs

func SocketUnitName added in v0.14.0

func SocketUnitName(appName types.ACName) string

SocketUnitName returns a systemd socket unit name for the given app name.

func SocketUnitPath added in v0.14.0

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

SocketUnitPath returns the path to the systemd socket file for the given app name.

func SocketWantPath added in v0.14.0

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

SocketWantPath returns the systemd sockets.target.wants symlink path for the given app name.

func VolumesToKvmDiskArgs added in v0.14.0

func VolumesToKvmDiskArgs(volumes []types.Volume) []string

VolumesToKvmDiskArgs prepares argument list to be passed to lkvm to configure shared volumes (only for "host" kind). Example return is ["--9p,src/folder,9ptag"].

func WriteDefaultTarget added in v0.14.0

func WriteDefaultTarget(p *stage1commontypes.Pod) error

WriteDefaultTarget writes the default.target unit file which is responsible for bringing up the applications

func WritePrepareAppTemplate added in v0.14.0

func WritePrepareAppTemplate(p *stage1commontypes.Pod) error

WritePrepareAppTemplate writes service unit files for preparing the pod's applications

Types

This section is empty.

Jump to

Keyboard shortcuts

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