sandbox

package
v0.0.0-...-02fb3ca Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrChecksStopped = errors.New("checks stopped")

Functions

This section is empty.

Types

type Checks

type Checks struct {
	UseClickhouseMetrics bool
	// contains filtered or unexported fields
}

func NewChecks

func NewChecks(sandbox *Sandbox, useClickhouseMetrics bool) *Checks

func (*Checks) GetMetrics

func (c *Checks) GetMetrics(ctx context.Context, timeout time.Duration) (*Metrics, error)

func (*Checks) Healthcheck

func (c *Checks) Healthcheck(ctx context.Context, alwaysReport bool)

func (*Checks) Start

func (c *Checks) Start(ctx context.Context)

func (*Checks) Stop

func (c *Checks) Stop()

type Cleanup

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

func NewCleanup

func NewCleanup() *Cleanup

func (*Cleanup) Add

func (c *Cleanup) Add(f func(ctx context.Context) error)

func (*Cleanup) AddPriority

func (c *Cleanup) AddPriority(f func(ctx context.Context) error)

func (*Cleanup) Run

func (c *Cleanup) Run(ctx context.Context) error

type Config

type Config struct {
	// TODO: Remove when the rootfs path is constant.
	// Only used for v1 rootfs paths format.
	BaseTemplateID string

	Vcpu  int64
	RamMB int64

	// TotalDiskSizeMB optional, now used only for metrics.
	TotalDiskSizeMB int64
	HugePages       bool

	AllowInternetAccess *bool

	Envd EnvdMetadata
}

type DiffCreator

type DiffCreator interface {
	// contains filtered or unexported methods
}

type EnvdMetadata

type EnvdMetadata struct {
	Vars        map[string]string
	AccessToken *string
	Version     string
}

type Factory

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

func NewFactory

func NewFactory(
	networkPool *network.Pool,
	devicePool *nbd.DevicePool,
	featureFlags *featureflags.Client,
	defaultAllowInternetAccess bool,
) *Factory

func (*Factory) CreateSandbox

func (f *Factory) CreateSandbox(
	ctx context.Context,
	config Config,
	runtime RuntimeMetadata,
	fcVersions fc.FirecrackerVersions,
	template template.Template,
	sandboxTimeout time.Duration,
	rootfsCachePath string,
	processOptions fc.ProcessOptions,
	apiConfigToStore *orchestrator.SandboxConfig,
) (s *Sandbox, e error)

CreateSandbox creates the sandbox. IMPORTANT: You must Close() the sandbox after you are done with it.

func (*Factory) GetEnvdInitRequestTimeout

func (f *Factory) GetEnvdInitRequestTimeout(ctx context.Context) time.Duration

func (*Factory) ResumeSandbox

func (f *Factory) ResumeSandbox(
	ctx context.Context,
	t template.Template,
	config Config,
	runtime RuntimeMetadata,
	traceID string,
	startedAt time.Time,
	endAt time.Time,
	apiConfigToStore *orchestrator.SandboxConfig,
) (s *Sandbox, e error)

ResumeSandbox resumes the sandbox from already saved template or snapshot. IMPORTANT: You must Close() the sandbox after you are done with it.

type MemoryDiffCreator

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

type Metadata

type Metadata struct {
	Config  Config
	Runtime RuntimeMetadata

	StartedAt time.Time
	EndAt     time.Time
	// contains filtered or unexported fields
}

type Metrics

type Metrics struct {
	Timestamp int64 `json:"ts"` // Unix Timestamp in UTC

	CPUCount       int64   `json:"cpu_count"`    // Total CPU cores
	CPUUsedPercent float64 `json:"cpu_used_pct"` // Percent rounded to 2 decimal places

	MemTotal int64 `json:"mem_total"` // Total virtual memory in bytes
	MemUsed  int64 `json:"mem_used"`  // Used virtual memory in bytes

	DiskUsed  int64 `json:"disk_used"`  // Used disk space in bytes
	DiskTotal int64 `json:"disk_total"` // Total disk space in bytes

	// Deprecated
	MemTotalMiB int64 `json:"mem_total_mib"` // Total virtual memory in MiB

	// Deprecated
	MemUsedMiB int64 `json:"mem_used_mib"` // Used virtual memory in MiB
}

type PostInitJSONBody

type PostInitJSONBody struct {
	EnvVars     *map[string]string `json:"envVars"`
	AccessToken *string            `json:"accessToken,omitempty"`
	HyperloopIP *string            `json:"hyperloopIP,omitempty"`
	Timestamp   *time.Time         `json:"timestamp,omitempty"`
}

type Resources

type Resources struct {
	Slot *network.Slot
	// contains filtered or unexported fields
}

type RootfsDiffCreator

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

type RuntimeMetadata

type RuntimeMetadata struct {
	TemplateID  string
	SandboxID   string
	ExecutionID string

	// TeamID optional, used only for logging
	TeamID string
}

type Sandbox

type Sandbox struct {
	*Resources
	*Metadata

	Template template.Template

	Checks *Checks

	// Deprecated: to be removed in the future
	// It was used to store the config to allow API restarts
	APIStoredConfig *orchestrator.SandboxConfig
	// contains filtered or unexported fields
}

func (*Sandbox) Close

func (s *Sandbox) Close(ctx context.Context) error

func (*Sandbox) FirecrackerVersions

func (s *Sandbox) FirecrackerVersions() fc.FirecrackerVersions

func (*Sandbox) LoggerMetadata

func (s *Sandbox) LoggerMetadata() sbxlogger.SandboxMetadata

func (*Sandbox) Pause

func (s *Sandbox) Pause(
	ctx context.Context,
	m metadata.Template,
) (*Snapshot, error)

func (*Sandbox) Stop

func (s *Sandbox) Stop(ctx context.Context) error

Stop kills the sandbox.

func (*Sandbox) Wait

func (s *Sandbox) Wait(ctx context.Context) error

func (*Sandbox) WaitForEnvd

func (s *Sandbox) WaitForEnvd(
	ctx context.Context,
	timeout time.Duration,
) (e error)

func (*Sandbox) WaitForExit

func (s *Sandbox) WaitForExit(ctx context.Context) error

type Snapshot

type Snapshot struct {
	MemfileDiff       build.Diff
	MemfileDiffHeader *header.Header
	RootfsDiff        build.Diff
	RootfsDiffHeader  *header.Header
	Snapfile          template.File
	Metafile          template.File
}

func (*Snapshot) Close

func (s *Snapshot) Close(_ context.Context) error

func (*Snapshot) Upload

func (s *Snapshot) Upload(
	ctx context.Context,
	persistence storage.StorageProvider,
	templateFiles storage.TemplateFiles,
) error

type TemplateBuild

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

func NewTemplateBuild

func NewTemplateBuild(memfileHeader *headers.Header, rootfsHeader *headers.Header, persistence storage.StorageProvider, files storage.TemplateFiles) *TemplateBuild

func (*TemplateBuild) Remove

func (t *TemplateBuild) Remove(ctx context.Context) error

func (*TemplateBuild) Upload

func (t *TemplateBuild) Upload(ctx context.Context, metadataPath string, fcSnapfilePath string, memfilePath *string, rootfsPath *string) chan error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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