host

package
v0.0.0-...-fb279e6 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CaBundlePath = "/etc/ssl/certs/ca-certificates.crt"
)
View Source
const (
	E2BRunDir = "/run/e2b" // store sandbox metadata files here

)

Variables

This section is empty.

Functions

func GetAccessTokenHashFromMMDS

func GetAccessTokenHashFromMMDS(ctx context.Context) (string, error)

GetAccessTokenHashFromMMDS reads the access token hash from MMDS. This is used to validate that /init requests come from the orchestrator.

func PollForMMDSOpts

func PollForMMDSOpts(ctx context.Context, mmdsChan chan<- *MMDSOpts, envVars *utils.Map[string, string])

Types

type CACertInstaller

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

CACertInstaller manages installation of a CA certificate into the VM's system trust bundle.

/etc/ssl/certs/ is bind-mounted from tmpfs at VM boot (see envd.service ExecStartPre), so all reads and writes bypass the NBD-backed filesystem and atomic cert rotation via os.Rename works within the same device.

func NewCACertInstaller

func NewCACertInstaller(logger *zerolog.Logger) *CACertInstaller

func (*CACertInstaller) Install

func (c *CACertInstaller) Install(ctx context.Context, certPEM string) error

Install injects certPEM into the system CA bundle. Returns an error if the foreground append fails so the caller can signal init failure to the orchestrator.

type MMDSOpts

type MMDSOpts struct {
	SandboxID            string `json:"instanceID"`
	TemplateID           string `json:"envID"`
	LogsCollectorAddress string `json:"address"`
	AccessTokenHash      string `json:"accessTokenHash"`
}

func (*MMDSOpts) AddOptsToJSON

func (opts *MMDSOpts) AddOptsToJSON(jsonLogs []byte) ([]byte, error)

func (*MMDSOpts) Update

func (opts *MMDSOpts) Update(sandboxID, templateID, collectorAddress string)

type Metrics

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

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

	// Deprecated
	// TODO: Remove when they are no longer used in orchestrator (https://linear.app/e2b/issue/E2B-2998/remove-envd-deprecated-metrics-when-not-used)
	MemTotalMiB uint64 `json:"mem_total_mib"` // Total virtual memory in MiB

	// Deprecated
	// TODO: Remove when no longer used in orchestrator
	MemUsedMiB uint64 `json:"mem_used_mib"` // Used virtual memory in MiB

	MemTotal uint64 `json:"mem_total"` // Total virtual memory in bytes
	MemUsed  uint64 `json:"mem_used"`  // Used virtual memory in bytes
	MemCache uint64 `json:"mem_cache"` // Cached memory (page cache) in bytes

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

func GetMetrics

func GetMetrics() (*Metrics, error)

Jump to

Keyboard shortcuts

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