Documentation
¶
Index ¶
- func BundleBuilder(ctx context.Context, result PullResult, spec workload.Spec) (*configs.Config, error)
- func CheckHealth(ctx context.Context, logger *zap.Logger, spec workload.Spec, ...) bool
- func StateDirPath() (string, error)
- type AdoptedProcess
- type ContainerRuntime
- type ExitStatus
- type ImagePuller
- type Process
- type ProcessHandle
- type PullResult
- type Puller
- type Runner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BundleBuilder ¶
func BundleBuilder(ctx context.Context, result PullResult, spec workload.Spec) (*configs.Config, error)
BundleBuilder produces a libcontainer Config from a pulled image.
Invariants:
- The caller is responsible for constructing the libcontainer Process (Args, Env, Cwd, User) from the image config and workload Spec.
- All containers get standard isolation namespaces and pseudo-fs mounts.
- Resources (CPU, memory) from the spec are mapped to cgroup limits. MemoryMB is converted from megabytes to bytes for the kernel. CPUShares of 0 means no limit is set (kernel default applies).
func CheckHealth ¶
func CheckHealth(ctx context.Context, logger *zap.Logger, spec workload.Spec, ctr *libcontainer.Container) bool
CheckHealth runs the spec's configured probe and returns true when the workload looks healthy. Empty probe means HTTP, preserving every old spec's behavior. Unknown probes, TCP without a mapped host port, and exec without a command are unhealthy, loudly: silent skips hide misconfiguration. The container handle serves exec probes only and may be nil for the others.
func StateDirPath ¶
stateDirPath returns the directory libcontainer uses to store container state. It lives under the user config directory at ~/.config/concord/cr/.
Types ¶
type AdoptedProcess ¶
type AdoptedProcess struct {
// contains filtered or unexported fields
}
AdoptedProcess implements ProcessHandle for containers that survived a Concord daemon restart or crash recovery.
Background: When Concord launches a fresh container, libcontainer constructs an in-memory *libcontainer.Process struct containing internal pipes, FIFOs, and synchronization state. cr.Process wraps that struct to route Wait() and Signal() through libcontainer's process manager.
However, when the Concord daemon restarts, containers created in previous runs may still be actively running in their Linux cgroups and network namespaces. Calling libcontainer.Load(stateDir, id) deserializes the container metadata from disk, but does NOT restore the original in-memory *libcontainer.Process handle or its launch FIFOs. Instead, ctr.State() provides only the host OS PID (InitProcessPid).
AdoptedProcess bridges this gap: it implements ProcessHandle directly against the host OS process primitives (os.FindProcess, os.Process.Signal, os.Process.Wait) without requiring an in-memory *libcontainer.Process. This allows the reconciler and monitoring loops to treat freshly started and adopted containers uniformly through the ProcessHandle interface.
func (*AdoptedProcess) Exited ¶
func (p *AdoptedProcess) Exited() <-chan ExitStatus
Exited returns a channel that receives the process exit status when terminated.
func (*AdoptedProcess) NamespacePID ¶
func (p *AdoptedProcess) NamespacePID() int
NamespacePID returns the host PID of the adopted container process.
type ContainerRuntime ¶
type ContainerRuntime struct {
// contains filtered or unexported fields
}
ContainerRuntime manages the lifecycle of libcontainer-backed workloads. Each container gets a subdirectory under stateDir where libcontainer stores its checkpoint data, FIFOs, and config state.
func NewRuntime ¶
func NewRuntime() (*ContainerRuntime, error)
NewRuntime creates a ContainerRuntime with its state directory under ~/.config/concord/cr/. Multiple containers share this state directory; each is keyed by its unique ID.
func (*ContainerRuntime) Create ¶
func (r *ContainerRuntime) Create(id string, cfg *configs.Config) (*libcontainer.Container, error)
Create sets up a new container with the given configs.Config but does not start any process inside it. Call Start to run the init process.
func (*ContainerRuntime) Start ¶
func (r *ContainerRuntime) Start(ctr *libcontainer.Container, proc *libcontainer.Process) (ProcessHandle, error)
Start runs the init process inside the container and returns once it is running (non-blocking). The container must have been created with Create first. Use ProcessHandle.Exited() to wait for the process to exit. It returns a ProcessHandle containing the process execution state and namespace PID.
type ExitStatus ¶
ExitStatus represents the outcome of process execution.
type ImagePuller ¶
type ImagePuller struct {
// contains filtered or unexported fields
}
ImagePuller pulls OCI container images from the local zot registry at localhost:8444 and extracts them into rootfs directories.
func NewImagePuller ¶
func NewImagePuller() *ImagePuller
NewImagePuller creates an ImagePuller targeting the local zot instance.
func (*ImagePuller) Pull ¶
func (p *ImagePuller) Pull(ctx context.Context, ref, bundleDir string) (*PullResult, error)
Pull fetches the image, resolves the platform, and extracts layers into the rootfs directory under bundleDir.
type Process ¶
type Process struct {
// contains filtered or unexported fields
}
Process implements ProcessHandle for libcontainer process management.
func NewProcess ¶
func NewProcess(process *libcontainer.Process, namespacePID int) *Process
NewProcess creates a Process handle and starts monitoring process exit asynchronously.
func (*Process) Exited ¶
func (p *Process) Exited() <-chan ExitStatus
Exited returns a channel that receives process exit notification.
func (*Process) NamespacePID ¶
NamespacePID returns the host PID of the container process.
type ProcessHandle ¶
type ProcessHandle interface {
NamespacePID() int
Signal(os.Signal) error
Exited() <-chan ExitStatus
}
ProcessHandle defines the interface for interacting with a running container process.
func AdoptProcess ¶
func AdoptProcess(pid int) ProcessHandle
AdoptProcess wraps an existing host OS process PID in an AdoptedProcess handle that monitors its exit state in the background.
type PullResult ¶
type PullResult struct {
Config *v1.ConfigFile
RootFS string
}
PullResult contains the extracted rootfs path and the image configuration for use by the bundle builder.
type Puller ¶
type Puller interface {
Pull(ctx context.Context, image, bundleDir string) (*PullResult, error)
}
Puller a definition of an interface that is required to be a puller.
type Runner ¶
type Runner interface {
Create(id string, cfg *configs.Config) (*libcontainer.Container, error)
Start(ctr *libcontainer.Container, proc *libcontainer.Process) (ProcessHandle, error)
}
Runner a definition of an interface that is required to be a runner.