Documentation
¶
Index ¶
- Constants
- Variables
- func ConstructCubeletReq(ctx context.Context, req *types.CreateCubeSandboxReq) (*cubebox.RunCubeSandboxRequest, error)
- func CreateImage(ctx context.Context, req *types.CreateImageReq) (rsp *types.Res)
- func CreateSandbox(ctx context.Context, req *types.CreateCubeSandboxReq) (rsp *types.CreateCubeSandboxRes)
- func DeleteImage(ctx context.Context, req *types.DeleteImageReq) (rsp *types.Res)
- func DeleteNode(ctx context.Context, nodeID string, force bool) error
- func DestroySandbox(ctx context.Context, req *types.DeleteCubeSandboxReq) (rsp *types.DeleteCubeSandboxRes)
- func Exec(ctx context.Context, req *types.ExecRequest) (rsp *types.Res)
- func Init(ctx context.Context, cfg *config.Config) error
- func ListSandbox(ctx context.Context, req *types.ListCubeSandboxReq) (rsp *types.ListCubeSandboxRes)
- func LookupSandboxEndAt(ctx context.Context, sandboxID string) int64
- func NormalizeSandboxIDParam(ctx context.Context, sandboxID string) (string, *types.Ret)
- func PreSchedule(ctx context.Context, req *types.CreateCubeSandboxReq) (*node.Node, error)
- func Refresh(ctx context.Context, req *types.RefreshSandboxRequest) (rsp *types.RefreshSandboxRes)
- func RegisterAfterCreateSandboxSuccessHook(hook CreateSandboxSuccessHook)
- func RegisterAfterDestroySandboxSuccessHook(hook func(context.Context, string) error)
- func RegisterAfterUpdateSandboxSuccessHook(hook UpdateSandboxSuccessHook)
- func ResetAfterCreateSandboxSuccessHooks()
- func ResetAfterDestroySandboxSuccessHooks()
- func ResetAfterUpdateSandboxSuccessHooks()
- func ResolveSandboxID(ctx context.Context, input string) (string, error)
- func SandboxInfo(ctx context.Context, req *types.GetCubeSandboxReq) (rsp *types.GetCubeSandboxRes)
- func SetAfterCreateSandboxSuccessHook(hook CreateSandboxSuccessHook)
- func SetAfterDestroySandboxSuccessHook(hook func(context.Context, string) error)
- func SetTimeout(ctx context.Context, req *types.SetTimeoutRequest) (rsp *types.SetTimeoutRes)
- func SetTimeoutProvider(p TimeoutProvider)
- func Update(ctx context.Context, req *types.UpdateRequest) (rsp *types.Res)
- type CreateSandboxSuccessHook
- type ExposedPortEndpoint
- type HostDirMountOption
- type TimeoutProvider
- type UpdateSandboxSuccessHook
Constants ¶
const ( ExposedPortModeTapIP = "tap_ip" ExposedPortModeHostPort = "host_port" )
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" )
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 ¶
var ErrNodeHasSandboxes = errors.New("node still has sandboxes")
Functions ¶
func ConstructCubeletReq ¶
func ConstructCubeletReq(ctx context.Context, req *types.CreateCubeSandboxReq) (*cubebox.RunCubeSandboxRequest, error)
func CreateImage ¶
func CreateSandbox ¶
func CreateSandbox(ctx context.Context, req *types.CreateCubeSandboxReq) (rsp *types.CreateCubeSandboxRes)
func DeleteImage ¶
func DeleteNode ¶
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 DestroySandbox ¶
func DestroySandbox(ctx context.Context, req *types.DeleteCubeSandboxReq) (rsp *types.DeleteCubeSandboxRes)
func ListSandbox ¶
func ListSandbox(ctx context.Context, req *types.ListCubeSandboxReq) (rsp *types.ListCubeSandboxRes)
func LookupSandboxEndAt ¶
LookupSandboxEndAt is a thin convenience wrapper around the installed TimeoutProvider's LookupEndAt.
func NormalizeSandboxIDParam ¶
NormalizeSandboxIDParam resolves a short or full sandbox ID for HTTP handlers.
func PreSchedule ¶
func Refresh ¶
func Refresh(ctx context.Context, req *types.RefreshSandboxRequest) (rsp *types.RefreshSandboxRes)
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 ¶
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 ¶
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 ¶
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.
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 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.
Source Files
¶
- envd_sidecar.go
- exposed_port_endpoint.go
- hostdir_mount.go
- id_resolve.go
- id_resolve_helpers.go
- image.go
- init.go
- node_deletion.go
- runtime_ref_hook.go
- sandbox_exec.go
- sandbox_info.go
- sandbox_list.go
- sandbox_migrate.go
- sandbox_remove.go
- sandbox_resume_pause.go
- sandbox_run.go
- sandbox_timeout.go
- sandbox_update.go
- template_identity.go
- timeout_provider.go
- util.go
- volume_mounts.go