pods

package
v0.0.0-...-8223eb1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: Apache-2.0 Imports: 32 Imported by: 17

README

Pods Library

This library provides functionality for launching and executing pod manifests. For integration with the intent store, see the intent package or preparer packages.

Documentation

Index

Constants

View Source
const (
	ConfigPathEnvVar               = "CONFIG_PATH"
	LaunchableIDEnvVar             = "LAUNCHABLE_ID"
	LaunchableRootEnvVar           = "LAUNCHABLE_ROOT"
	PodIDEnvVar                    = "POD_ID"
	PodHomeEnvVar                  = "POD_HOME"
	PodUniqueKeyEnvVar             = "POD_UNIQUE_KEY"
	PlatformConfigPathEnvVar       = "PLATFORM_CONFIG_PATH"
	ResourceLimitsPathEnvVar       = "RESOURCE_LIMIT_PATH" // ResourceLimits is a superset of PlatformConfig
	LaunchableRestartTimeoutEnvVar = "RESTART_TIMEOUT"
	TerminationGracePeriod         = 1 * time.Hour
)
View Source
const DefaultPath = "/data/pods"

Variables

View Source
var (
	Log logging.Logger
)
View Source
var (
	// NestedCgroups causes the p2-preparer to use a hierarchical cgroup naming scheme when
	// creating new launchables.
	NestedCgroups = param.Bool("nested_cgroups", false)
)
View Source
var NoCurrentManifest error = fmt.Errorf("No current manifest for this pod")
View Source
var NopFinishExec = []string{"/bin/true"} // type must match preparerconfig

Functions

func ComputeUniqueName

func ComputeUniqueName(id types.PodID, uniqueKey types.PodUniqueKey) string

Types

type Factory

type Factory interface {
	NewUUIDPod(id types.PodID, uniqueKey types.PodUniqueKey) (*Pod, error)
	NewLegacyPod(id types.PodID) *Pod
	SetOSVersionDetector(osversion.Detector)
	SetDockerClient(dockerclient.Client)
}

func NewFactory

func NewFactory(podRoot string, node types.NodeName, fetcher uri.Fetcher, requireFile string, readOnlyPolicy ReadOnlyPolicy) Factory

type HookFactory

type HookFactory interface {
	NewHookPod(id types.PodID) *Pod
}

func NewHookFactory

func NewHookFactory(hookRoot string, node types.NodeName, fetcher uri.Fetcher) HookFactory

type ManifestFinder

type ManifestFinder interface {
	Find(pod Pod) (manifest.Manifest, error)
}

type Pod

type Pod struct {
	// ID of the pod, i.e. result of ID() called on the manifest defining the pod
	Id types.PodID

	SV                runit.SV
	ServiceBuilder    *runit.ServiceBuilder
	P2Exec            string
	DefaultTimeout    time.Duration // this is the default timeout for stopping and restarting services in this pod
	LogExec           runit.Exec
	FinishExec        runit.Exec
	Fetcher           uri.Fetcher
	ManifestFinder    ManifestFinder
	OSVersionDetector osversion.Detector

	// Pod will not start if file is not present
	RequireFile string

	DockerClient *dockerclient.Client
	// contains filtered or unexported fields
}

func PodFromPodHome

func PodFromPodHome(node types.NodeName, home string) (*Pod, error)

func PodFromPodHomeWithReqFile

func PodFromPodHomeWithReqFile(node types.NodeName, home string, requireFile string) (*Pod, error)

func (*Pod) BuildRunitServices

func (pod *Pod) BuildRunitServices(launchables []launch.Launchable, newManifest manifest.Manifest) error

Write servicebuilder *.yaml file and run servicebuilder, which will register runit services for this pod.

func (*Pod) ConfigDir

func (pod *Pod) ConfigDir() string

func (*Pod) CreateCgroupForPod

func (pod *Pod) CreateCgroupForPod() error

func (*Pod) CurrentManifest

func (pod *Pod) CurrentManifest() (manifest.Manifest, error)

func (*Pod) EnvDir

func (pod *Pod) EnvDir() string

func (*Pod) FinishExecForExecutable

func (pod *Pod) FinishExecForExecutable(launchable launch.Launchable, executable launch.Executable) runit.Exec

func (*Pod) Halt

func (pod *Pod) Halt(manifest manifest.Manifest, force bool) (bool, error)

func (*Pod) Home

func (pod *Pod) Home() string

func (*Pod) Install

func (pod *Pod) Install(manifest manifest.Manifest, verifier auth.ArtifactVerifier, artifactRegistry artifact.Registry, containerRegistryAuthStr string, dockerImageDirectoryWhitelist []string) error

Install will ensure that executables for all required services are present on the host machine and are set up to run. In the case of Hoist artifacts (which is the only format supported currently, this will set up runit services.).

func (*Pod) Launch

func (pod *Pod) Launch(manifest manifest.Manifest) (bool, error)

Launch will attempt to start every launchable listed in the pod manifest. Errors encountered during the launch process will be logged, but will not stop attempts to launch other launchables in the same pod. If any services fail to start, the first return bool will be false. If an error occurs when writing the current manifest to the pod directory, an error will be returned.

func (*Pod) Launchables

func (pod *Pod) Launchables(manifest manifest.Manifest) ([]launch.Launchable, error)

func (*Pod) Node

func (pod *Pod) Node() types.NodeName

func (*Pod) PostActivate

func (pod *Pod) PostActivate(launchables []launch.Launchable) error

runs post-activate for listed launchables

func (*Pod) Prune

func (pod *Pod) Prune(max size.ByteCount, manifest manifest.Manifest)

func (*Pod) ReadOnly

func (pod *Pod) ReadOnly() bool

func (*Pod) Services

func (pod *Pod) Services(manifest manifest.Manifest) ([]runit.Service, error)

func (*Pod) SetFinishExec

func (pod *Pod) SetFinishExec(finishExec []string)

func (*Pod) SetLogBridgeExec

func (pod *Pod) SetLogBridgeExec(logExec []string)

func (*Pod) SetSubsystemer

func (pod *Pod) SetSubsystemer(s cgroups.Subsystemer)

SetSubsystemer is useful for tests

func (*Pod) StartLaunchables

func (pod *Pod) StartLaunchables(launchables []launch.Launchable) bool

func (*Pod) Uninstall

func (pod *Pod) Uninstall() error

func (*Pod) UniqueKey

func (pod *Pod) UniqueKey() types.PodUniqueKey

func (*Pod) UniqueName

func (pod *Pod) UniqueName() string

A unique name for a pod instance, useful for avoiding filename conflicts. Typically <id>-<uuid> if the pod has a uuid, and simply <id> if it does not have a uuid

This is exported because being able to generate a unique deterministic string for pods is useful in hooks for example.

func (*Pod) Verify

func (pod *Pod) Verify(manifest manifest.Manifest, authPolicy auth.Policy) error

func (*Pod) WriteCurrentManifest

func (pod *Pod) WriteCurrentManifest(manifest manifest.Manifest) (string, error)

type ReadOnlyPolicy

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

func NewReadOnlyPolicy

func NewReadOnlyPolicy(defaultReadOnly bool, whitelist []types.PodID, blacklist []types.PodID) ReadOnlyPolicy

func (*ReadOnlyPolicy) IsReadOnly

func (p *ReadOnlyPolicy) IsReadOnly(pod types.PodID) bool

Jump to

Keyboard shortcuts

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