shim

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2025 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NodeLabel                        = "zeropod.ctrox.dev/node"
	PortsAnnotationKey               = "zeropod.ctrox.dev/ports-map"
	ContainerNamesAnnotationKey      = "zeropod.ctrox.dev/container-names"
	ScaleDownDurationAnnotationKey   = "zeropod.ctrox.dev/scaledown-duration"
	DisableCheckpoiningAnnotationKey = "zeropod.ctrox.dev/disable-checkpointing"
	PreDumpAnnotationKey             = "zeropod.ctrox.dev/pre-dump"
	MigrateAnnotationKey             = "zeropod.ctrox.dev/migrate"
	LiveMigrateAnnotationKey         = "zeropod.ctrox.dev/live-migrate"
	CRIContainerNameAnnotation       = "io.kubernetes.cri.container-name"
	CRIContainerTypeAnnotation       = "io.kubernetes.cri.container-type"
	CRIPodNameAnnotation             = "io.kubernetes.cri.sandbox-name"
	CRIPodNamespaceAnnotation        = "io.kubernetes.cri.sandbox-namespace"
	CRIPodUIDAnnotation              = "io.kubernetes.cri.sandbox-uid"
)
View Source
const RuntimeName = "io.containerd.zeropod.v2"

Variables

View Source
var (
	ErrAlreadyRestored      = errors.New("container is already restored")
	ErrRestoreRequestFailed = errors.New("restore request failed")
)

Functions

func FinishRestore

func FinishRestore(ctx context.Context, id string, cfg *Config, startTime time.Time) error

func GetNetworkNS

func GetNetworkNS(spec *specs.Spec) (string, error)

GetNetworkNS reads the bundle's OCI spec and returns the network NS path of the container.

func GetPIDNS

func GetPIDNS(spec *specs.Spec) (string, error)

GetPIDNS reads the bundle's OCI spec and returns the PID NS path of the container.

func GetSpec

func GetSpec(bundlePath string) (*specs.Spec, error)

func MigrationRestore

func MigrationRestore(ctx context.Context, r *task.CreateTaskRequest, cfg *Config) (skipStart bool, err error)

MigrationRestore requests a restore from the node. If a matching migration is found, it sets the Checkpoint path in the CreateTaskRequest.

Types

type Config

type Config struct {
	ZeropodContainerNames []string
	Ports                 []uint16
	ScaleDownDuration     time.Duration
	DisableCheckpointing  bool
	PreDump               bool
	Migrate               []string
	LiveMigrate           string
	ContainerName         string
	ContainerType         string
	PodName               string
	PodNamespace          string
	PodUID                string
	ContainerdNamespace   string
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(ctx context.Context, spec *specs.Spec) (*Config, error)

NewConfig uses the annotations from the container spec to create a new typed ZeropodConfig config.

func (Config) AnyMigrationEnabled

func (cfg Config) AnyMigrationEnabled() bool

func (Config) IsZeropodContainer

func (cfg Config) IsZeropodContainer() bool

func (Config) LiveMigrationEnabled

func (cfg Config) LiveMigrationEnabled() bool

type Container

type Container struct {
	*runc.Container
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, cfg *Config, id string, cr *sync.Mutex, pt stdio.Platform, events chan *v1.ContainerStatus) (*Container, error)

func (*Container) AddCheckpointedPID

func (c *Container) AddCheckpointedPID(pid int)

AddCheckpointedPID registers a new pid that should be considered checkpointed.

func (*Container) CancelScaleDown

func (c *Container) CancelScaleDown()

func (*Container) CheckpointedPID

func (c *Container) CheckpointedPID(pid int) bool

CheckpointedPID indicates if the pid has been checkpointed before.

func (*Container) Config

func (c *Container) Config() *Config

func (*Container) DeleteCheckpointedPID

func (c *Container) DeleteCheckpointedPID(pid int)

DeleteCheckpointedPID deletes a pid from the map of checkpointed pids.

func (*Container) Evac

func (c *Container) Evac(ctx context.Context, scaledDown bool) error

func (*Container) GetMetrics

func (c *Container) GetMetrics() *v1.ContainerMetrics

func (*Container) ID

func (c *Container) ID() string

func (*Container) InitialProcess

func (c *Container) InitialProcess() process.Process

func (*Container) MigrationEnabled

func (c *Container) MigrationEnabled() bool

func (*Container) Process

func (c *Container) Process() process.Process

func (*Container) Register

func (c *Container) Register(ctx context.Context, container *runc.Container) error

func (*Container) RegisterPostRestore

func (c *Container) RegisterPostRestore(f func(*runc.Container, HandleStartedFunc))

func (*Container) RegisterPreRestore

func (c *Container) RegisterPreRestore(f func() HandleStartedFunc)

func (*Container) Restore

func (c *Container) Restore(ctx context.Context) (*runc.Container, process.Process, error)

func (*Container) ScaledDown

func (c *Container) ScaledDown() bool

func (*Container) ScheduleScaleDown

func (c *Container) ScheduleScaleDown() error

func (*Container) SetScaledDown

func (c *Container) SetScaledDown(scaledDown bool)

func (*Container) SetSkipStart

func (c *Container) SetSkipStart(skip bool)

func (*Container) SkipStart

func (c *Container) SkipStart() bool

func (*Container) Status

func (c *Container) Status() *v1.ContainerStatus

func (*Container) Stop

func (c *Container) Stop(ctx context.Context)

func (*Container) StopActivator

func (c *Container) StopActivator(ctx context.Context)

type HandleStartedFunc

type HandleStartedFunc func(*runc.Container, process.Process)

Directories

Path Synopsis
Package io has been copied from https://github.com/containerd/containerd/tree/c07fb699a9a0c9792d21a759c87d0d60de11bfb9/internal/cri/io with some small changes to avoid importing k8s.io/cri-api (except in tests) and github.com/docker/go-metrics
Package io has been copied from https://github.com/containerd/containerd/tree/c07fb699a9a0c9792d21a759c87d0d60de11bfb9/internal/cri/io with some small changes to avoid importing k8s.io/cri-api (except in tests) and github.com/docker/go-metrics

Jump to

Keyboard shortcuts

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