sandbox

package
v0.0.0-...-72af66c Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: Apache-2.0, BSD-2-Clause Imports: 54 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExposedPortModeTapIP    = "tap_ip"
	ExposedPortModeHostPort = "host_port"
)
View Source
const (
	// AnnotationHostDirMount must match the annotation key that CubeAPI
	// writes when it lifts metadata["host-mount"] onto the sandbox
	// CreateSandboxRequest; see CubeAPI/src/handlers/sandboxes.rs
	// (const HOSTDIR_MOUNT_KEY). Keep these in lockstep, otherwise
	// host-mount requests are silently dropped.
	AnnotationHostDirMount = "host-mount"
)
View Source
const AnnotationPluginVolumeMounts = "plugin-volume-mounts"

AnnotationPluginVolumeMounts is the annotation key CubeAPI uses to forward VolumeMount entries for plugin_volume volumes. The value is a JSON array of {name, container_path, readonly?} objects.

Variables

View Source
var ErrNodeHasSandboxes = errors.New("node still has sandboxes")

Functions

func CreateImage

func CreateImage(ctx context.Context, req *types.CreateImageReq) (rsp *types.Res)

func DeleteImage

func DeleteImage(ctx context.Context, req *types.DeleteImageReq) (rsp *types.Res)

func DeleteNode

func DeleteNode(ctx context.Context, nodeID string, force bool) error

DeleteNode verifies the node is empty through Cubelet before removing its control-plane metadata. force bypasses the inventory check but never the nodemeta isolation requirement.

func Exec

func Exec(ctx context.Context, req *types.ExecRequest) (rsp *types.Res)

func Init

func Init(ctx context.Context, cfg *config.Config) error

func ListSandbox

func ListSandbox(ctx context.Context, req *types.ListCubeSandboxReq) (rsp *types.ListCubeSandboxRes)

func LookupSandboxEndAt

func LookupSandboxEndAt(ctx context.Context, sandboxID string) int64

LookupSandboxEndAt is a thin convenience wrapper around the installed TimeoutProvider's LookupEndAt.

func NormalizeSandboxIDParam

func NormalizeSandboxIDParam(ctx context.Context, sandboxID string) (string, *types.Ret)

NormalizeSandboxIDParam resolves a short or full sandbox ID for HTTP handlers.

func PreSchedule

func PreSchedule(ctx context.Context, req *types.CreateCubeSandboxReq) (*node.Node, error)

func Refresh

Refresh implements POST /cube/sandbox/refresh. Semantically identical to SetTimeout: refresh(d) rebases the idle clock and sets TimeoutSeconds = d.

func RegisterAfterCreateSandboxSuccessHook

func RegisterAfterCreateSandboxSuccessHook(hook CreateSandboxSuccessHook)

RegisterAfterCreateSandboxSuccessHook appends a hook to the create chain.

func RegisterAfterDestroySandboxSuccessHook

func RegisterAfterDestroySandboxSuccessHook(hook func(context.Context, string) error)

RegisterAfterDestroySandboxSuccessHook appends a hook to the destroy chain. Hooks run sequentially in registration order; an individual hook's error is returned to the caller of runAfterDestroySandboxSuccessHook (joined when multiple hooks fail) but does NOT short-circuit later hooks.

func RegisterAfterUpdateSandboxSuccessHook

func RegisterAfterUpdateSandboxSuccessHook(hook UpdateSandboxSuccessHook)

RegisterAfterUpdateSandboxSuccessHook appends a hook to the update chain. Hooks run sequentially in registration order.

func ResetAfterCreateSandboxSuccessHooks

func ResetAfterCreateSandboxSuccessHooks()

ResetAfterCreateSandboxSuccessHooks clears every registered create hook. Test-only helper.

func ResetAfterDestroySandboxSuccessHooks

func ResetAfterDestroySandboxSuccessHooks()

ResetAfterDestroySandboxSuccessHooks clears every registered destroy hook. Test-only helper; production code never calls it.

func ResetAfterUpdateSandboxSuccessHooks

func ResetAfterUpdateSandboxSuccessHooks()

ResetAfterUpdateSandboxSuccessHooks clears every registered update hook. Test-only helper.

func ResolveSandboxID

func ResolveSandboxID(ctx context.Context, input string) (string, error)

ResolveSandboxID accepts a short or full sandbox ID and returns the canonical full ID.

func SandboxInfo

func SandboxInfo(ctx context.Context, req *types.GetCubeSandboxReq) (rsp *types.GetCubeSandboxRes)

func SetAfterCreateSandboxSuccessHook

func SetAfterCreateSandboxSuccessHook(hook CreateSandboxSuccessHook)

SetAfterCreateSandboxSuccessHook keeps the historical single-registration signature working: it appends rather than replaces.

func SetAfterDestroySandboxSuccessHook

func SetAfterDestroySandboxSuccessHook(hook func(context.Context, string) error)

SetAfterDestroySandboxSuccessHook is retained for backward compatibility with single-registration callers (templatecenter). It now appends to the chain rather than replacing it; callers that genuinely need replacement semantics should use ResetAfterDestroySandboxSuccessHooks first.

func SetTimeout

func SetTimeout(ctx context.Context, req *types.SetTimeoutRequest) (rsp *types.SetTimeoutRes)

SetTimeout implements POST /cube/sandbox/timeout. It is the master-side counterpart of CubeAPI's SetTimeoutRequest -> SetTimeoutResponse.

func SetTimeoutProvider

func SetTimeoutProvider(p TimeoutProvider)

SetTimeoutProvider installs the singleton implementation. lifecycle.Init calls it exactly once during process startup.

func Update

func Update(ctx context.Context, req *types.UpdateRequest) (rsp *types.Res)

Types

type CreateSandboxSuccessHook

type CreateSandboxSuccessHook func(ctx context.Context, sandboxID, hostID, hostIP string, req *types.CreateCubeSandboxReq) error

CreateSandboxSuccessHook is invoked after a sandbox is successfully created on a cubelet node. Implementations should be cheap (or non-blocking) and MUST NOT cause the create path to fail when they error: the caller logs the error and continues.

type ExposedPortEndpoint

type ExposedPortEndpoint struct {
	Address       string
	Mode          string
	HostIP        string
	SandboxIP     string
	ContainerPort int32
	HostPort      int32
}

func ResolveExposedPortEndpoint

func ResolveExposedPortEndpoint(callerHostIP string, proxyMap *proxytypes.SandboxProxyMap, containerPort int32) (*ExposedPortEndpoint, error)

type HostDirMountOption

type HostDirMountOption struct {
	HostPath string `json:"hostPath"`

	MountPath string `json:"mountPath"`

	ReadOnly bool `json:"readOnly,omitempty"`
}

type TimeoutProvider

type TimeoutProvider interface {
	RefreshTimeout(ctx context.Context, sandboxID string, timeoutSeconds int) (endAtMs int64, err error)
	LookupEndAt(ctx context.Context, sandboxID string) (endAtMs int64, err error)
}

TimeoutProvider is the contract sandbox_timeout.go uses to mutate the lifecycle metadata channel without taking a hard build-time dependency on pkg/lifecycle. lifecycle.Init() injects a concrete implementation at startup;

type UpdateSandboxSuccessHook

type UpdateSandboxSuccessHook func(ctx context.Context, sandboxID, instanceType, action, requestID string)

UpdateSandboxSuccessHook is invoked after a sandbox pause / resume RPC (POST /cube/sandbox/update) succeeds. Subscribers use it to fan out state transitions to downstream consumers such as the lifecycle metadata channel. The hook MUST NOT fail the update path — implementations should log and swallow errors.

Action carries "pause" or "resume" (validated upstream). RequestID is forwarded from the incoming request for log correlation.

Directories

Path Synopsis
Package types common definitions of common types of cube master.
Package types common definitions of common types of cube master.

Jump to

Keyboard shortcuts

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