Documentation
¶
Index ¶
- Constants
- func GetQosFromReq(req *cubebox.RunCubeSandboxRequest, key string) (*disk.RateLimiter, error)
- func RecordCreateMetric(ctx context.Context, err error, id string, cost time.Duration)
- func RecordCreateMetricIfGreaterThan(ctx context.Context, err error, id string, cost time.Duration, ...)
- func RecordDestroyMetric(ctx context.Context, err error, id string, cost time.Duration)
- func WithCreateContext(ctx context.Context, createContext *CreateContext) context.Context
- type BaseWorkflowInfo
- func (m *BaseWorkflowInfo) AddMetric(err error, id string, t time.Duration)
- func (b *BaseWorkflowInfo) GetAppID() int64
- func (b *BaseWorkflowInfo) GetCPU() int64
- func (b *BaseWorkflowInfo) GetInstanceType() string
- func (b *BaseWorkflowInfo) GetMemory() int64
- func (m *BaseWorkflowInfo) GetMetric() []*Metric
- func (b *BaseWorkflowInfo) GetNumaNode() int32
- func (b *BaseWorkflowInfo) GetPCIMode() string
- func (b *BaseWorkflowInfo) GetSandboxID() string
- func (b *BaseWorkflowInfo) GetSubUin() string
- func (b *BaseWorkflowInfo) GetUin() string
- func (b *BaseWorkflowInfo) IsPCIPFMode() bool
- type CleanContext
- type CreateContext
- func (m *CreateContext) AddMetric(err error, id string, t time.Duration)
- func (b *CreateContext) GetInstanceType() string
- func (m *CreateContext) GetMetric() []*Metric
- func (b *CreateContext) GetQos(key string) (*disk.RateLimiter, error)
- func (b *CreateContext) GetRegion() string
- func (b *CreateContext) GetSnapshotMode() snapshotmode.Mode
- func (b *CreateContext) GetSnapshotTemplateID() (string, bool)
- func (b *CreateContext) IsColdBoot() bool
- func (b *CreateContext) IsColdBootFromSnapshot() bool
- func (b *CreateContext) IsCreateSnapshot() bool
- func (b *CreateContext) IsCubeboxV2() bool
- func (b *CreateContext) IsGuestMountRestore() bool
- func (b *CreateContext) IsPauseResume() bool
- func (b *CreateContext) IsRetoreSnapshot() bool
- func (b *CreateContext) WantsSnapshotRestore() bool
- type DestroyContext
- type Engine
- func (e *Engine) AddCleaupFlow(f Flow)
- func (e *Engine) AddFlow(k string, f *Workflow)
- func (e *Engine) CleanUp(ctx context.Context, opts *CleanContext) error
- func (e *Engine) Create(ctx context.Context, opts *CreateContext) error
- func (e *Engine) Destroy(ctx context.Context, opts *DestroyContext) error
- func (e *Engine) GetFlowOnFlyingRequests(name string) int64
- func (e *Engine) GetFlowPeakRequests(name string) int64
- func (s *Engine) ID() string
- func (e *Engine) Init(ctx context.Context, opts *InitInfo) error
- func (e *Engine) RegisterMetrics(register *metrictype.CollectRegister) error
- func (e *Engine) SetFlowLimit(name string, limit int64)
- type Flow
- type InitInfo
- type Metric
- type ReqContext
- type RestartPrior
- type Retain
- type Step
- type VolumeRefEvent
- type Workflow
Constants ¶
const ( KCreateContext contextKey = "kCreateContext" KInitContext contextKey = "KInitContext" KDestroyContext contextKey = "KDestroyContext" )
Variables ¶
This section is empty.
Functions ¶
func GetQosFromReq ¶
func GetQosFromReq(req *cubebox.RunCubeSandboxRequest, key string) (*disk.RateLimiter, error)
func RecordCreateMetric ¶
func RecordDestroyMetric ¶
func WithCreateContext ¶
func WithCreateContext(ctx context.Context, createContext *CreateContext) context.Context
Types ¶
type BaseWorkflowInfo ¶
type BaseWorkflowInfo struct {
SandboxID string
CPU int64
Memory int64
PCIMode string
NumaNode int32
IsRollBack bool
AppID int64
Uin string
SubUin string
// contains filtered or unexported fields
}
func (*BaseWorkflowInfo) GetAppID ¶
func (b *BaseWorkflowInfo) GetAppID() int64
func (*BaseWorkflowInfo) GetCPU ¶
func (b *BaseWorkflowInfo) GetCPU() int64
func (*BaseWorkflowInfo) GetInstanceType ¶
func (b *BaseWorkflowInfo) GetInstanceType() string
func (*BaseWorkflowInfo) GetMemory ¶
func (b *BaseWorkflowInfo) GetMemory() int64
func (*BaseWorkflowInfo) GetNumaNode ¶
func (b *BaseWorkflowInfo) GetNumaNode() int32
func (*BaseWorkflowInfo) GetPCIMode ¶
func (b *BaseWorkflowInfo) GetPCIMode() string
func (*BaseWorkflowInfo) GetSandboxID ¶
func (b *BaseWorkflowInfo) GetSandboxID() string
func (*BaseWorkflowInfo) GetSubUin ¶
func (b *BaseWorkflowInfo) GetSubUin() string
func (*BaseWorkflowInfo) GetUin ¶
func (b *BaseWorkflowInfo) GetUin() string
func (*BaseWorkflowInfo) IsPCIPFMode ¶
func (b *BaseWorkflowInfo) IsPCIPFMode() bool
type CreateContext ¶
type CreateContext struct {
BaseWorkflowInfo
ReqInfo *cubebox.RunCubeSandboxRequest
NetworkInfo provider.NetworkProvider
StorageInfo interface{}
CgroupInfo interface{}
VolumeInfo interface{}
Failover bool
UserData *cubeboxstore.UserData
CubeBoxCreated bool
NetFile *netfile.CubeboxNetfile
LocalRunTemplate *templatetypes.LocalRunTemplate
// VolumeRefEvents collects node-level plugin_volume ref-count transitions
// (0→1) observed during this create, to be reported to CubeMaster in the
// create response ext_info on success.
VolumeRefEvents []VolumeRefEvent
// SnapshotMode is the artifact mode of the snapshot this sandbox is
// created from. It is empty for ordinary creates and is always full for
// pause/resume. Master supplies it through the typed proto field.
SnapshotMode snapshotmode.Mode
// SnapshotWritableLayer is the overlay upper ("disk/<id>") this create must mount.
SnapshotWritableLayer string
// PriorWritableLayer is the layer on the paused row Resume is replacing.
PriorWritableLayer string
// IsRestart rebuilds a sandbox that already has an ID, disk and network.
// Plugins consult Retain and WantsSnapshotRestore instead of guessing.
IsRestart bool
SavedContainerIDs map[int]string
RestartPrior *RestartPrior
}
func GetCreateContext ¶
func GetCreateContext(ctx context.Context) *CreateContext
func (*CreateContext) GetInstanceType ¶
func (b *CreateContext) GetInstanceType() string
func (*CreateContext) GetQos ¶
func (b *CreateContext) GetQos(key string) (*disk.RateLimiter, error)
func (*CreateContext) GetRegion ¶
func (b *CreateContext) GetRegion() string
func (*CreateContext) GetSnapshotMode ¶
func (b *CreateContext) GetSnapshotMode() snapshotmode.Mode
func (*CreateContext) GetSnapshotTemplateID ¶
func (b *CreateContext) GetSnapshotTemplateID() (string, bool)
func (*CreateContext) IsColdBoot ¶
func (b *CreateContext) IsColdBoot() bool
IsColdBoot reports that this create starts a brand-new VM instead of restoring guest memory. Restart and create-from-fs-only both qualify.
It is the first predicate every other restore decision consults: a cold boot must never set app_snapshot_restore, a memory URL or a memory lineage.
func (*CreateContext) IsColdBootFromSnapshot ¶
func (b *CreateContext) IsColdBootFromSnapshot() bool
IsColdBootFromSnapshot is the narrower CBRI decision: only a create from an fs-only snapshot reads the package (config.json/metadata.json). Restart reuses its retained disk and must stay on the ordinary create branch.
func (*CreateContext) IsCreateSnapshot ¶
func (b *CreateContext) IsCreateSnapshot() bool
func (*CreateContext) IsCubeboxV2 ¶
func (b *CreateContext) IsCubeboxV2() bool
func (*CreateContext) IsGuestMountRestore ¶
func (b *CreateContext) IsGuestMountRestore() bool
IsGuestMountRestore is true when Create restores a VM whose guest already has virtiofs + container binds live in memory: pause resume or FromSnap. Create-from-template only has appsnapshot.template.id — that memory is a clean template and still needs virtio_rw mounted for newly attached volumes.
func (*CreateContext) IsPauseResume ¶
func (b *CreateContext) IsPauseResume() bool
IsPauseResume is true when Master asks Cubelet to recreate the same sandbox from a pause snapshot (cube.master.pause.snapshot.id). Distinct from create-from-template / create-from-normal-snapshot: guest memory already has container bind mounts, so Cubelet must not re-emit propagation exec.mount / umount annotations.
func (*CreateContext) IsRetoreSnapshot ¶
func (b *CreateContext) IsRetoreSnapshot() bool
func (*CreateContext) WantsSnapshotRestore ¶
func (b *CreateContext) WantsSnapshotRestore() bool
WantsSnapshotRestore reports whether this create should restore guest memory from a snapshot. A restart keeps the disk and cold-boots.
type DestroyContext ¶
type DestroyContext struct {
BaseWorkflowInfo
DestroyInfo *cubebox.DestroyCubeSandboxRequest
// IsRestartDestroy keeps the sandbox ID's disk, network, volume metadata
// and cubebox row. The VM, shim and cgroup are still torn down.
// What is kept is decided only by Retain.
IsRestartDestroy bool
// VolumeRefEvents collects node-level plugin_volume ref-count transitions
// (1→0) observed during this destroy, to be reported to CubeMaster in the
// destroy response ext_info.
VolumeRefEvents []VolumeRefEvent
}
func (*DestroyContext) GetInstanceType ¶
func (b *DestroyContext) GetInstanceType() string
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) AddCleaupFlow ¶
func (*Engine) GetFlowOnFlyingRequests ¶
func (*Engine) GetFlowPeakRequests ¶
func (*Engine) RegisterMetrics ¶
func (e *Engine) RegisterMetrics(register *metrictype.CollectRegister) error
func (*Engine) SetFlowLimit ¶
type InitInfo ¶
type InitInfo struct {
BaseWorkflowInfo
NetCIDR string
MVMInnerIP net.IP
TapInitNum int
}
type ReqContext ¶
type RestartPrior ¶
type RestartPrior struct {
RestartCount int32
LastRestartAt int64
LastSuccessfulRestartAt int64
LastFailedRestartAt int64
LastExitCode int32
LastExitReason string
// StatusSeq is the last value reported to CubeMaster. A rebuilt CubeBox
// continues from it so a newer report is not dropped as stale.
StatusSeq int64
OriginalRequest []byte
}
RestartPrior is the bookkeeping copied onto the CubeBox built by a restart.
type Retain ¶
Retain is what a destroy must keep. The zero value keeps nothing. Restart is the only destroy that keeps anything; every plugin asks Retain instead of growing its own restart condition.
func RetainFor ¶
func RetainFor(opts *DestroyContext) Retain
RetainFor is the one decision of what a restart-destroy keeps.
func ReuseFor ¶
func ReuseFor(opts *CreateContext) Retain
ReuseFor is the one decision of what a restart-create reuses. It is the create-side pair of RetainFor.
type Step ¶
func (*Step) AppendFlow ¶
type VolumeRefEvent ¶
type VolumeRefEvent struct {
VolumeID string `json:"volume_id"`
Referenced int `json:"referenced"`
}
VolumeRefEvent records a node-level plugin_volume reference-state change that must be reported back to CubeMaster so it can maintain a cross-node ref-count in t_cube_volume.
An event is emitted ONLY when this node's reference state for the volume flips: Referenced=1 when the node started referencing it (node-local count 0→1) and Referenced=0 when it stopped (1→0). Repeat references on the same node (count 1→2, 2→1, …) do NOT produce an event.