instance

package
v0.0.0-...-8109336 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: Apache-2.0 Imports: 31 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.

Variables

This section is empty.

Functions

func MockInstance

func MockInstance(envID, instanceID, consulToken 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 FC

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

func NewFC

func NewFC(
	ctx context.Context,
	tracer trace.Tracer,
	slot *IPSlot,
	fsEnv *InstanceFiles,
	mmdsMetadata *MmdsMetadata,
) *FC

func (*FC) Start

func (fc *FC) Start(
	ctx context.Context,
	tracer trace.Tracer,
) error

func (*FC) Stop

func (fc *FC) Stop(ctx context.Context, tracer trace.Tracer) error

func (*FC) Wait

func (fc *FC) Wait() error

type IPSlot

type IPSlot struct {
	ConsulToken string

	InstanceID  string
	NodeShortID string
	KVKey       string
	SlotIdx     int
}

func NewSlot

func NewSlot(ctx context.Context, tracer trace.Tracer, nodeID, instanceID, consulToken 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) 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 Instance

type Instance struct {
	Files *InstanceFiles
	Slot  *IPSlot
	FC    *FC

	EnvID string
	// contains filtered or unexported fields
}

func NewInstance

func NewInstance(
	ctx context.Context,
	tracer trace.Tracer,
	config *InstanceConfig,
	dns *DNS,
) (*Instance, error)

func (*Instance) CleanupAfterFCStop

func (i *Instance) CleanupAfterFCStop(
	ctx context.Context,
	tracer trace.Tracer,
	dns *DNS,
)

func (*Instance) EnsureClockSync

func (i *Instance) EnsureClockSync(ctx context.Context) error

type InstanceConfig

type InstanceConfig struct {
	EnvID                 string
	AllocID               string
	NodeID                string
	ConsulToken           string
	EnvsDisk              string
	InstanceID            string
	LogsProxyAddress      string
	TraceID               string
	TeamID                string
	KernelVersion         string
	KernelMountDir        string
	KernelsDir            string
	KernelName            string
	FirecrackerBinaryPath string
	UFFDBinaryPath        string
	HugePages             bool
}

type InstanceFiles

type InstanceFiles struct {
	UFFDSocketPath *string

	EnvPath      string
	BuildDirPath string

	EnvInstancePath string
	SocketPath      string

	KernelDirPath      string
	KernelMountDirPath string

	FirecrackerBinaryPath string
	UFFDBinaryPath        string
}

func (*InstanceFiles) Cleanup

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

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"`
}

Jump to

Keyboard shortcuts

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