sandbox

package
v0.0.0-...-af2bad0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BuildIDName  = "build_id"
	RootfsName   = "rootfs.ext4"
	SnapfileName = "snapfile"
	MemfileName  = "memfile"

	BuildDirName        = "builds"
	EnvInstancesDirName = "env-instances"
)
View Source
const (

	// This is the maximum number of IP addresses that can be allocated.
	IPSlotsSize = octetSize * octetSize

	HostSnapshotMask = 32
	VMask            = 30
	TapMask          = 30
)

We are using a more debuggable IP address allocation for now that only covers 255 addresses.

View Source
const (
	SigkillWait      = 5 * time.Second
	SigkillWaitCheck = 100 * time.Millisecond
)

Variables

This section is empty.

Functions

func MockInstance

func MockInstance(envID, instanceID string, dns *DNS, keepAlive time.Duration)

func Must

func Must[T any](obj T, err error) T

Types

type DNS

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

func NewDNS

func NewDNS() (*DNS, error)

func (*DNS) Add

func (d *DNS) Add(ips *IPSlot) error

func (*DNS) Remove

func (d *DNS) Remove(ips *IPSlot) error

type IPSlot

type IPSlot struct {
	ConsulToken string

	InstanceID string
	KVKey      string
	SlotIdx    int
}

func NewSlot

func NewSlot(ctx context.Context, tracer trace.Tracer, consulClient *consul.Client, instanceID string) (*IPSlot, error)

func (*IPSlot) CreateNetwork

func (ips *IPSlot) CreateNetwork(
	ctx context.Context,
	tracer trace.Tracer,
	dns *DNS,
) error

func (*IPSlot) HostSnapshotCIDR

func (ips *IPSlot) HostSnapshotCIDR() string

func (*IPSlot) HostSnapshotIP

func (ips *IPSlot) HostSnapshotIP() string

func (*IPSlot) HostSnapshotMask

func (ips *IPSlot) HostSnapshotMask() int

func (*IPSlot) NamespaceID

func (ips *IPSlot) NamespaceID() string

func (*IPSlot) NamespaceSnapshotIP

func (ips *IPSlot) NamespaceSnapshotIP() string

func (*IPSlot) Release

func (ips *IPSlot) Release(ctx context.Context, tracer trace.Tracer, consulClient *consul.Client) error

func (*IPSlot) RemoveNetwork

func (ipSlot *IPSlot) RemoveNetwork(ctx context.Context, tracer trace.Tracer, dns *DNS) error

func (*IPSlot) TapCIDR

func (ips *IPSlot) TapCIDR() string

func (*IPSlot) TapIP

func (ips *IPSlot) TapIP() string

func (*IPSlot) TapMask

func (ips *IPSlot) TapMask() int

func (*IPSlot) TapName

func (ips *IPSlot) TapName() string

func (*IPSlot) VMask

func (ips *IPSlot) VMask() int

func (*IPSlot) VethCIDR

func (ips *IPSlot) VethCIDR() string

func (*IPSlot) VethIP

func (ips *IPSlot) VethIP() string

func (*IPSlot) VethName

func (ips *IPSlot) VethName() string

func (*IPSlot) VpeerCIDR

func (ips *IPSlot) VpeerCIDR() string

func (*IPSlot) VpeerIP

func (ips *IPSlot) VpeerIP() string

func (*IPSlot) VpeerName

func (ips *IPSlot) VpeerName() string

type MmdsMetadata

type MmdsMetadata struct {
	InstanceID string `json:"instanceID"`
	EnvID      string `json:"envID"`
	Address    string `json:"address"`
	TraceID    string `json:"traceID"`
	TeamID     string `json:"teamID"`
}

type Sandbox

type Sandbox struct {
	Sandbox   *orchestrator.SandboxConfig
	StartedAt time.Time
	TraceID   string
	// contains filtered or unexported fields
}

func NewSandbox

func NewSandbox(
	ctx context.Context,
	tracer trace.Tracer,
	consul *consul.Client,
	dns *DNS,
	config *orchestrator.SandboxConfig,
	traceID string,
) (*Sandbox, error)

func (*Sandbox) CleanupAfterFCStop

func (s *Sandbox) CleanupAfterFCStop(
	ctx context.Context,
	tracer trace.Tracer,
	consul *consul.Client,
	dns *DNS,
)

func (*Sandbox) EnsureClockSync

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

func (*Sandbox) FcPid

func (s *Sandbox) FcPid() int

func (*Sandbox) SlotIdx

func (s *Sandbox) SlotIdx() int

func (*Sandbox) Stop

func (s *Sandbox) Stop(ctx context.Context, tracer trace.Tracer)

func (*Sandbox) UffdPid

func (s *Sandbox) UffdPid() *int

func (*Sandbox) Wait

func (s *Sandbox) Wait(ctx context.Context, tracer trace.Tracer) (err error)

type SandboxFiles

type SandboxFiles struct {
	UFFDSocketPath *string

	EnvPath      string
	BuildDirPath string

	EnvInstancePath string
	SocketPath      string

	KernelDirPath      string
	KernelMountDirPath string

	FirecrackerBinaryPath string
	UFFDBinaryPath        string
}

func (*SandboxFiles) Cleanup

func (env *SandboxFiles) Cleanup(
	ctx context.Context,
	tracer trace.Tracer,
) error

func (*SandboxFiles) Ensure

func (env *SandboxFiles) Ensure(ctx context.Context) error

Jump to

Keyboard shortcuts

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