containerd

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: EPL-2.0 Imports: 66 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultDataPlaneStopBudget is the aligned systemd TimeoutStopSec budget for data-plane stop.
	DefaultDataPlaneStopBudget = 120 * time.Second
	// DefaultShimReapBudgetCap is the maximum time spent reaping managed shims during stop/bootstrap.
	DefaultShimReapBudgetCap = 30 * time.Second
	// DefaultPostStopShimVerifyCap is the maximum verify reap after containerd stop when primary reap failed.
	DefaultPostStopShimVerifyCap = 10 * time.Second
)

Variables

View Source
var (
	ErrContainerdSpawnFailure   = errors.New("containerd spawn failure")
	ErrContainerdReadiness      = errors.New("containerd readiness failure")
	ErrContainerdExitedEarly    = errors.New("containerd exited before ready")
	ErrContainerdStopTimeout    = errors.New("containerd stop timeout")
	ErrContainerdUnexpectedExit = errors.New("containerd unexpected exit")
	ErrContainerdReconfigure    = errors.New("containerd reconfigure failure")
)

Functions

func CleanupRuntimeArtifacts

func CleanupRuntimeArtifacts() error

CleanupRuntimeArtifacts removes stale runtime artifacts used by embedded containerd. It intentionally preserves persistent image/layer data under EdgeletContainerdRootDir.

func CleanupStaleRuntimeTasks

func CleanupStaleRuntimeTasks() error

CleanupStaleRuntimeTasks removes orphaned runtime task directories under EdgeletContainerdStateDir. Preserves EdgeletContainerdRootDir (images/layers).

func CleanupStaleRuntimeTasksWithRetry added in v1.0.1

func CleanupStaleRuntimeTasksWithRetry() error

CleanupStaleRuntimeTasksWithRetry removes stale runtime task directories with bounded EBUSY retries after shim reap. Bootstrap continues when dirs remain busy.

func FindEmbeddedContainerdChildPIDs

func FindEmbeddedContainerdChildPIDs() ([]int, error)

FindEmbeddedContainerdChildPIDs returns PIDs whose cmdline includes --edgelet-containerd-child.

func MaybeRunChildProcess

func MaybeRunChildProcess(args []string) (bool, error)

MaybeRunChildProcess runs containerd in child mode when the daemon is invoked with the dedicated internal child argument.

func PrepareEmbeddedContainerdBootstrap added in v1.0.1

func PrepareEmbeddedContainerdBootstrap()

PrepareEmbeddedContainerdBootstrap stops orphans, reaps shims, and cleans stale tasks before embedded containerd start or retry.

func ReapManagedShimsForSocket added in v1.0.1

func ReapManagedShimsForSocket(socketPath string, remainingBudget time.Duration) error

ReapManagedShimsForSocket terminates containerd-shim processes bound to socketPath and stops orphaned --edgelet-containerd-child processes for the edgelet socket scope.

func ReapManagedShimsUntilClear added in v1.0.1

func ReapManagedShimsUntilClear(socketPath string, remainingBudget time.Duration) error

ReapManagedShimsUntilClear retries managed shim/child teardown until processes are gone or remainingBudget is exhausted.

func ReapShimsForStaleTask added in v1.0.1

func ReapShimsForStaleTask(socketPath, taskID string, remainingBudget time.Duration) error

ReapShimsForStaleTask terminates managed shims bound to a stale runtime task ID.

func RemainingStopBudget added in v1.0.1

func RemainingStopBudget(stopStarted time.Time, totalBudget time.Duration) time.Duration

RemainingStopBudget returns the stop time left from totalBudget since stopStarted.

func ResetShimReapRemainingBudget added in v1.0.1

func ResetShimReapRemainingBudget()

ResetShimReapRemainingBudget restores the default shim-reap budget cap.

func SetShimReapRemainingBudget added in v1.0.1

func SetShimReapRemainingBudget(remaining time.Duration)

SetShimReapRemainingBudget configures the shim-reap slice for the next Stop/reap call.

func StopOrphanedEmbeddedContainerd added in v1.0.1

func StopOrphanedEmbeddedContainerd() error

StopOrphanedEmbeddedContainerd stops leftover embedded containerd children from /proc.

Types

type ErrContainerdReconfigureOperation

type ErrContainerdReconfigureOperation struct {
	Stage   string
	Attempt int
	Err     error
}

func (*ErrContainerdReconfigureOperation) Details

func (e *ErrContainerdReconfigureOperation) Details() map[string]any

func (*ErrContainerdReconfigureOperation) Error

func (*ErrContainerdReconfigureOperation) Unwrap

type ErrRuntimeHandlerUnavailable

type ErrRuntimeHandlerUnavailable struct {
	Handler    string
	Candidates []string
}

ErrRuntimeHandlerUnavailable indicates a requested handler is missing or not eligible.

func (*ErrRuntimeHandlerUnavailable) Error

func (*ErrRuntimeHandlerUnavailable) Unwrap

func (e *ErrRuntimeHandlerUnavailable) Unwrap() error

type RuntimeCatalogEntry

type RuntimeCatalogEntry struct {
	Handler     string
	Binary      string
	Path        string
	RuntimeType string
	Family      RuntimeFamily
}

RuntimeCatalogEntry is one runtime handler detection result.

func BuildRuntimeCatalog

func BuildRuntimeCatalog() []RuntimeCatalogEntry

BuildRuntimeCatalog discovers supported runtimes from PATH. Only discovered handlers are returned.

func ValidateRuntimeHandlerEligibility

func ValidateRuntimeHandlerEligibility(handler string, catalog []RuntimeCatalogEntry) (RuntimeCatalogEntry, error)

ValidateRuntimeHandlerEligibility returns a runtime entry only when handler exists in catalog and is eligible.

type RuntimeFamily

type RuntimeFamily string
const (
	RuntimeFamilyRunc RuntimeFamily = "runc"
	RuntimeFamilyShim RuntimeFamily = "shim"
)

type Service

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

Service manages the embedded containerd child-process lifecycle.

func NewAttachedService

func NewAttachedService() *Service

NewAttachedService monitors an externally managed containerd (Plan 11 data-plane unit).

func NewService

func NewService() *Service

NewService creates an uninitialized containerd service.

func (*Service) IsAttachOnly

func (s *Service) IsAttachOnly() bool

IsAttachOnly reports whether this service only monitors an external containerd process.

func (*Service) IsHealthy

func (s *Service) IsHealthy() bool

IsHealthy returns true when containerd is reachable and the CRI runtime plugin is usable.

func (*Service) Ready

func (s *Service) Ready() <-chan struct{}

Ready returns a channel that closes when containerd is ready to accept requests.

func (*Service) Reap

func (s *Service) Reap() error

Reap waits for the service goroutine to finish.

func (*Service) Reconfigure

func (s *Service) Reconfigure() error

Reconfigure rewrites containerd config and performs a controlled restart.

func (*Service) Run

func (s *Service) Run() error

Run starts containerd as a managed child process and blocks until it exits.

func (*Service) SetUnexpectedExitHandler

func (s *Service) SetUnexpectedExitHandler(handler func(error))

func (*Service) Start

func (s *Service) Start() error

Start launches the service in background and waits for readiness.

func (*Service) Stop

func (s *Service) Stop()

Stop keeps backward-compatible behavior while enforcing escalation.

func (*Service) StopForce

func (s *Service) StopForce() error

StopForce force-kills the child process and waits for completion.

func (*Service) StopGraceful

func (s *Service) StopGraceful() error

StopGraceful requests a graceful shutdown and waits for completion.

func (*Service) WaitReady

func (s *Service) WaitReady(timeout time.Duration) error

WaitReady waits for the service to become ready up to timeout.

Jump to

Keyboard shortcuts

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