katautils

package
v0.0.0-...-f04a7a5 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

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

View Source
const SYSLOGTAG = "kata"

SYSLOGTAG is for a consistently named syslog identifier

Variables

View Source
var GetKernelParamsFunc = getKernelParams

GetKernelParamsFunc use a variable to allow tests to modify its value

Functions

func CreateContainer

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

CreateContainer create a container

func CreateRuntimeHooks

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

func CreateSandbox

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

CreateSandbox create a sandbox container

func EnterNetNS

func EnterNetNS(networkID 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 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 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 SetConfigOptions

func SetConfigOptions(n, runtimeConfig, sysRuntimeConfig string)

SetConfigOptions will override some of the defaults settings.

func SetEphemeralStorageType

func SetEphemeralStorageType(ociSpec specs.Spec, disableGuestEmptyDir bool) 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 VerifyContainerID

func VerifyContainerID(id string) error

VerifyContainerID checks if the specified container ID (or sandbox ID) is valid.

func WriteFile

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

WriteFile write data into specified file

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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