katautils

package
v0.0.0-...-04f2983 Latest Latest
Warning

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

Go to latest
Published: May 5, 2021 License: Apache-2.0 Imports: 35 Imported by: 14

README

Kata utilities packages

The katautils package contains useful functions that are shared by various parts of the codebase, including the runtime and the container v2 shim.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DockerLikeCtrEngines = []string{"docker", "podman"}
)
View Source
var GetKernelParamsFunc = getKernelParams

GetKernelParamsFunc use a variable to allow tests to modify its value

Functions

func AddContainerIDMapping

func AddContainerIDMapping(ctx context.Context, containerID, sandboxID string) error

AddContainerIDMapping add a container id mapping to sandbox id

func CreateContainer

func CreateContainer(ctx context.Context, vci vc.VC, sandbox vc.VCSandbox, ociSpec specs.Spec, rootFs vc.RootFs, containerID, bundlePath, console string, disableOutput, builtIn bool) (vc.Process, error)

CreateContainer create a container

func CreateSandbox

func CreateSandbox(ctx context.Context, vci vc.VC, ociSpec specs.Spec, runtimeConfig oci.RuntimeConfig, rootFs vc.RootFs,
	containerID, bundlePath, console string, disableOutput, systemdCgroup, builtIn bool) (_ vc.VCSandbox, _ vc.Process, err error)

CreateSandbox create a sandbox container

func CreateTracer

func CreateTracer(name string) (opentracing.Tracer, error)

CreateTracer create a tracer

func DelContainerIDMapping

func DelContainerIDMapping(ctx context.Context, containerID string) error

DelContainerIDMapping delete container id mapping from a sandbox

func EnterNetNS

func EnterNetNS(netNSPath string, cb func() error) error

EnterNetNS is free from any call to a go routine, and it calls into runtime.LockOSThread(), meaning it won't be executed in a different thread than the one expected by the caller.

func FetchContainerIDMapping

func FetchContainerIDMapping(containerID string) (string, error)

FetchContainerIDMapping This function assumes it should find only one file inside the container ID directory. If there are several files, we could not determine which file name corresponds to the sandbox ID associated, and this would throw an error.

func FileExists

func FileExists(path string) bool

FileExists test is a file exiting or not

func GetDefaultConfigFilePaths

func GetDefaultConfigFilePaths() []string

GetDefaultConfigFilePaths returns a list of paths that will be considered as configuration files in priority order.

func GetDefaultHypervisorConfig

func GetDefaultHypervisorConfig() vc.HypervisorConfig

func GetFileContents

func GetFileContents(file string) (string, error)

GetFileContents return the file contents as a string.

func HandleFactory

func HandleFactory(ctx context.Context, vci vc.VC, runtimeConfig *oci.RuntimeConfig)

HandleFactory set the factory

func IsBlockDevice

func IsBlockDevice(filePath string) bool

IsBlockDevice returns true if the give path is a block device

func LoadConfiguration

func LoadConfiguration(configPath string, ignoreLogging, builtIn bool) (resolvedConfigPath string, config oci.RuntimeConfig, err error)

LoadConfiguration loads the configuration file and converts it into a runtime configuration.

If ignoreLogging is true, the system logger will not be initialised nor will this function make any log calls.

All paths are resolved fully meaning if this function does not return an error, all paths are valid at the time of the call.

func PostStartHooks

func PostStartHooks(ctx context.Context, spec specs.Spec, cid, bundlePath string) error

PostStartHooks run the hooks just after start container

func PostStopHooks

func PostStopHooks(ctx context.Context, spec specs.Spec, cid, bundlePath string) error

PostStopHooks run the hooks after stop container

func PreStartHooks

func PreStartHooks(ctx context.Context, spec specs.Spec, cid, bundlePath string) error

PreStartHooks run the hooks before start container

func ResolvePath

func ResolvePath(path string) (string, error)

ResolvePath returns the fully resolved and expanded value of the specified path.

func RunCommand

func RunCommand(args []string) (string, error)

RunCommand returns the commands space-trimmed standard output on success

func RunCommandFull

func RunCommandFull(args []string, includeStderr bool) (string, error)

RunCommandFull returns the commands space-trimmed standard output and error on success. Note that if the command fails, the requested output will still be returned, along with an error.

func SetConfigOptions

func SetConfigOptions(n, runtimeConfig, sysRuntimeConfig string)

SetConfigOptions will override some of the defaults settings.

func SetCtrsMapTreePath

func SetCtrsMapTreePath(path string)

SetCtrsMapTreePath let the testcases change the ctrsMapTreePath to a test dir

func SetEphemeralStorageType

func SetEphemeralStorageType(ociSpec specs.Spec) specs.Spec

SetEphemeralStorageType sets the mount type to 'ephemeral' if the mount source path is provisioned by k8s for ephemeral storage. For the given pod ephemeral volume is created only once backed by tmpfs inside the VM. For successive containers of the same pod the already existing volume is reused.

func SetKernelParams

func SetKernelParams(runtimeConfig *oci.RuntimeConfig) error

SetKernelParams adds the user-specified kernel parameters (from the configuration file) to the defaults so that the former take priority.

func SetLogger

func SetLogger(ctx context.Context, logger *logrus.Entry, level logrus.Level)

SetLogger sets the logger for the factory.

func SetupNetworkNamespace

func SetupNetworkNamespace(config *vc.NetworkConfig) error

SetupNetworkNamespace create a network namespace

func StopTracing

func StopTracing(ctx context.Context)

StopTracing ends all tracing, reporting the spans to the collector.

func Trace

func Trace(parent context.Context, name string) (opentracing.Span, context.Context)

Trace creates a new tracing span based on the specified name and parent context.

func WriteFile

func WriteFile(filePath string, data string, fileMode os.FileMode) error

WriteFile write data into specified file

Types

type CtrEngine

type CtrEngine struct {
	Name string
}

func (*CtrEngine) Create

func (e *CtrEngine) Create(image string) (string, error)

func (*CtrEngine) GetRootfs

func (e *CtrEngine) GetRootfs(ctrID string, dir string) error

func (*CtrEngine) Init

func (e *CtrEngine) Init(name string) (string, error)

func (*CtrEngine) Inspect

func (e *CtrEngine) Inspect(image string) (string, error)

func (*CtrEngine) Pull

func (e *CtrEngine) Pull(image string) (string, error)

func (*CtrEngine) Rm

func (e *CtrEngine) Rm(ctrID string) (string, error)

Jump to

Keyboard shortcuts

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