models

package
v0.0.0-...-99a0925 Latest Latest
Warning

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

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

Documentation

Overview

Package models contains database schema and ORM model definitions for Cube Master project.

Index

Constants

View Source
const MaxPrivateDataLen = 1024

MaxPrivateDataLen is the maximum length of Create-hook private_data in bytes (Go len()). The DB column is varchar(1024) under utf8mb4 (character-length), same as token; byte validation is a conservative upper bound for opaque plugin state (typically ASCII / short UTF-8).

View Source
const MaxVolumeNameLen = 128

MaxVolumeNameLen is the maximum length of a customer-supplied volume name. Must match the varchar(128) columns for volume_id and name in t_cube_volume.

View Source
const VolumeTableName = "t_cube_volume"

VolumeTableName is the canonical MySQL table name for volume records.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArtifactNodePlacement

type ArtifactNodePlacement struct {
	ArtifactID string `json:"artifact_id" gorm:"column:artifact_id;primaryKey"`
	NodeID     string `json:"node_id" gorm:"column:node_id;primaryKey"`
	NodeIP     string `json:"node_ip" gorm:"column:node_ip"`
	CreatedAt  int64  `json:"created_at" gorm:"column:created_at"`
}

ArtifactNodePlacement records that a given ext4 rootfs artifact is (or was) physically distributed to a node. Unlike t_cube_template_replica it is not tied to a template's lifecycle: rows persist until the artifact itself is fully cleaned up, so last-owner-cleanup / GC can enumerate every node that ever received the artifact even after all referencing replicas are deleted.

func (ArtifactNodePlacement) TableName

func (ArtifactNodePlacement) TableName() string

type HostInfo

type HostInfo struct {
	gorm.Model
	InsID        string `json:"InstanceID" gorm:"column:ins_id"`
	IP           string `json:"HostIP" gorm:"column:ip"`
	CpuTotal     int    `json:"Cpu" gorm:"column:cpu_total"`
	MemMBTotal   int64  `json:"Mem" gorm:"column:mem_mb_total"`
	Zone         string `json:"Zone" gorm:"column:zone"`
	Region       string `json:"Region" gorm:"column:region"`
	DataDiskGB   int64  `json:"DataDiskGB" gorm:"column:data_disk_gb"`
	SysDiskGB    int64  `json:"SysDiskGB" gorm:"column:sys_disk_gb"`
	InstanceType string `json:"InstanceType" gorm:"column:instance_type"`
	ClusterLabel string `json:"ClusterLabel" gorm:"column:cube_cluster_label"`
	UUID         string `json:"UUID" gorm:"column:uuid"`

	LiveStatus          string `json:"LiveStatus" gorm:"column:live_status"`
	HostStatus          string `json:"HostStatus" gorm:"column:host_status"`
	QuotaCpu            int64  `json:"QuotaCpu" gorm:"column:quota_cpu"`
	QuotaMem            int64  `json:"QuotaMem" gorm:"column:quota_mem_mb"`
	CreateConcurrentNum int64  `json:"CreateConcurrentNum" gorm:"column:create_concurrent_num"`
	MaxMvmNum           int64  `json:"MaxMvmNum" gorm:"column:max_mvm_num"`
	OssClusterLabel     string `json:"OssClusterLabel" gorm:"column:oss_cluster_label"`
}

func (HostInfo) TableName

func (HostInfo) TableName() string

type HostTypeInfo

type HostTypeInfo struct {
	gorm.Model
	InstanceType string `json:"InstanceType" gorm:"column:instance_type"`
	CPUType      string `json:"CPUType" gorm:"column:cpu_type"`
}

func (HostTypeInfo) TableName

func (HostTypeInfo) TableName() string

type InstanceInfo

type InstanceInfo struct {
	gorm.Model
	InsID         string `json:"InstanceID" gorm:"column:ins_id"`
	UUID          string `json:"Uuid" gorm:"column:uuid"`
	HostIP        string `json:"HostIP" gorm:"column:host_ip"`
	HostID        string `json:"HostId" gorm:"column:host_id"`
	InstanceState string `json:"InstanceState" gorm:"column:ins_state"`

	CPU     int64  `json:"Cpu" gorm:"column:cpu"`
	Mem     int64  `json:"Mem" gorm:"column:mem"`
	CPUType string `json:"CpuType" gorm:"column:cpu_type"`
	Zone    string `json:"Zone" gorm:"column:zone"`
	Region  string `json:"Region" gorm:"column:region"`

	ImageID                 string `json:"ImageID" gorm:"column:image_id"`
	SystemDisk              string `json:"SystemDisk" gorm:"column:system_disk"`
	DataDisks               string `json:"DataDisks" gorm:"column:data_disks"`
	PrivateIPAddresses      string `json:"PrivateIpAddresses" gorm:"column:private_ip_addresses"`
	PrivateIP               string `json:"PrivateIp" gorm:"column:private_ip"`
	PrirvateIPCnt           int64  `json:"PrivateIpCnt" gorm:"column:private_ip_cnt"`
	SecurityGroupIDS        string `json:"SecurityGroupIds" gorm:"column:security_ids"`
	VpcID                   string `json:"VpcId" gorm:"column:vpc_id"`
	MacAddress              string `json:"MacAddress" gorm:"column:mac_address"`
	SubnetID                string `json:"SubnetId" gorm:"column:subnet_id"`
	DiskState               string `json:"DiskState" gorm:"column:disk_state"`
	FailMsg                 string `json:"FailMsg" gorm:"column:fail_msg"`
	CamRoleName             string `json:"CamRoleName" gorm:"column:cam_role_name"`
	DisasterRecoverGroupIds string `json:"DisasterRecoverGroupIds" gorm:"column:disaster_recover_group_ids"`
}

func (InstanceInfo) TableName

func (InstanceInfo) TableName() string

type InstanceUserData

type InstanceUserData struct {
	gorm.Model
	InsID    string `json:"InsID" gorm:"column:ins_id"`
	UserData string `json:"UserData" gorm:"column:user_data"`
}

func (InstanceUserData) TableName

func (InstanceUserData) TableName() string

type MachineInfo

type MachineInfo struct {
	gorm.Model
	InsID              string `json:"InstanceID,omitempty" gorm:"column:ins_id"`
	DeviceClass        string `json:"DeviceClass,omitempty" gorm:"column:device_class"`
	DeviceID           int64  `json:"DeviceId,omitempty" gorm:"column:device_id"`
	HostIP             string `json:"HostIp,omitempty" gorm:"column:host_ip"`
	InstanceFamily     string `json:"InstanceFamily,omitempty" gorm:"column:instance_family"`
	DedicatedClusterId string `json:"DedicatedClusterId,omitempty" gorm:"column:dedicated_cluster_id"`
	VirtualNodeQuota   string `json:"VirtualNodeQuota,omitempty" gorm:"column:virtual_node_quota"`
}

func (MachineInfo) TableName

func (MachineInfo) TableName() string

type NodeComponentVersion

type NodeComponentVersion struct {
	ID           uint   `gorm:"primarykey"`
	NodeID       string `gorm:"column:node_id"`
	Component    string `gorm:"column:component"`
	Version      string `gorm:"column:version"`
	Commit       string `gorm:"column:commit"`
	BuildTime    string `gorm:"column:build_time"`
	Source       string `gorm:"column:source"`
	ReportedUnix int64  `gorm:"column:reported_unix"`
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

NodeComponentVersion records the real version of a single component on a single node. It intentionally does NOT embed gorm.Model: the table uses a (node_id, component) unique key and the writer physically deletes stale rows, so a soft-delete column would resurrect tombstoned rows on the next upsert and hide them from Find().

func (NodeComponentVersion) TableName

func (NodeComponentVersion) TableName() string

type NodeRegistration

type NodeRegistration struct {
	gorm.Model
	NodeID              string `gorm:"column:node_id"`
	HostIP              string `gorm:"column:host_ip"`
	GRPCPort            int    `gorm:"column:grpc_port"`
	LabelsJSON          string `gorm:"column:labels_json"`
	CapacityJSON        string `gorm:"column:capacity_json"`
	AllocatableJSON     string `gorm:"column:allocatable_json"`
	InstanceType        string `gorm:"column:instance_type"`
	ClusterLabel        string `gorm:"column:cluster_label"`
	QuotaCPU            int64  `gorm:"column:quota_cpu"`
	QuotaMemMB          int64  `gorm:"column:quota_mem_mb"`
	CreateConcurrentNum int64  `gorm:"column:create_concurrent_num"`
	MaxMvmNum           int64  `gorm:"column:max_mvm_num"`
	HostFactsJSON       string `gorm:"column:host_facts_json"`
	// Promoted queryable host-fact keys, denormalised from HostFactsJSON so the
	// compatible-nodes lookup can filter server-side on the two required
	// (blocking) restore-compat keys. CPUVendor/CPUModel are informational
	// (empty on ARM) and are stored but not indexed. host_facts_json remains the
	// source of truth for the full fact set (taint gate + informational dims).
	CPUVendor         string `gorm:"column:cpu_vendor"`
	CPUModel          string `gorm:"column:cpu_model"`
	CPUIDHash         string `gorm:"column:cpuid_hash"`
	HostKernelRelease string `gorm:"column:host_kernel_release"`
}

func (NodeRegistration) TableName

func (NodeRegistration) TableName() string

type NodeStatus

type NodeStatus struct {
	gorm.Model
	NodeID             string `gorm:"column:node_id"`
	ConditionsJSON     string `gorm:"column:conditions_json"`
	ImagesJSON         string `gorm:"column:images_json"`
	LocalTemplatesJSON string `gorm:"column:local_templates_json"`
	HeartbeatUnix      int64  `gorm:"column:heartbeat_unix"`
	Healthy            bool   `gorm:"column:healthy"`
}

func (NodeStatus) TableName

func (NodeStatus) TableName() string

type RootfsArtifact

type RootfsArtifact struct {
	gorm.Model
	ArtifactID              string `json:"artifact_id" gorm:"column:artifact_id"`
	TemplateSpecFingerprint string `json:"template_spec_fingerprint" gorm:"column:template_spec_fingerprint"`
	SourceImageRef          string `json:"source_image_ref" gorm:"column:source_image_ref"`
	SourceImageDigest       string `json:"source_image_digest" gorm:"column:source_image_digest"`
	MasterNodeID            string `json:"master_node_id" gorm:"column:master_node_id"`
	MasterNodeIP            string `json:"master_node_ip" gorm:"column:master_node_ip"`
	Ext4Path                string `json:"ext4_path" gorm:"column:ext4_path"`
	Ext4SHA256              string `json:"ext4_sha256" gorm:"column:ext4_sha256"`
	Ext4SizeBytes           int64  `json:"ext4_size_bytes" gorm:"column:ext4_size_bytes"`
	ImageConfigJSON         string `json:"image_config_json" gorm:"column:image_config_json"`
	GeneratedRequestJSON    string `json:"generated_request_json" gorm:"column:generated_request_json"`
	WritableLayerSize       string `json:"writable_layer_size" gorm:"column:writable_layer_size"`
	DownloadToken           string `json:"download_token" gorm:"column:download_token"`
	Status                  string `json:"status" gorm:"column:status"`
	LastError               string `json:"last_error" gorm:"column:last_error"`
	GCDeadline              int64  `json:"gc_deadline" gorm:"column:gc_deadline"`

	// CubeEgress CA bake metadata (see design/cube-egress-ca-bake.md).
	// Used for audit/triage; the artifact reuse cache key folds
	// CubeEgressCAFingerprint into TemplateSpecFingerprint, so a CA
	// rotation invalidates stale artifacts automatically.
	CubeEgressCABaked          bool   `json:"cube_egress_ca_baked" gorm:"column:cube_egress_ca_baked"`
	CubeEgressCAFingerprint    string `json:"cube_egress_ca_fingerprint" gorm:"column:cube_egress_ca_fingerprint"`
	CubeEgressCATargetsWritten int    `json:"cube_egress_ca_targets_written" gorm:"column:cube_egress_ca_targets_written"`
}

func (RootfsArtifact) TableName

func (RootfsArtifact) TableName() string

type SandboxSpec

type SandboxSpec struct {
	gorm.Model
	SandboxID    string `json:"sandbox_id" gorm:"column:sandbox_id"`
	TemplateID   string `json:"template_id" gorm:"column:template_id"`
	InstanceType string `json:"instance_type" gorm:"column:instance_type"`
	NetworkType  string `json:"network_type" gorm:"column:network_type"`
	HostID       string `json:"host_id" gorm:"column:host_id"`
	HostIP       string `json:"host_ip" gorm:"column:host_ip"`
	RequestJSON  string `json:"request_json" gorm:"column:request_json"`
	Backfilled   bool   `json:"backfilled" gorm:"column:backfilled"`
}

SandboxSpec persists the canonical create-time spec of a sandbox so that downstream control-plane flows (snapshot create, debug inspection, etc.) can recover the full request without forcing the original caller to re-supply it. The record is written on sandbox-create success and removed on sandbox-destroy success.

func (SandboxSpec) TableName

func (SandboxSpec) TableName() string

type SnapshotRuntimeActive

type SnapshotRuntimeActive struct {
	SandboxID   string     `json:"sandbox_id" gorm:"column:sandbox_id;primaryKey"`
	BindingType string     `json:"binding_type" gorm:"column:binding_type;primaryKey"`
	SnapshotID  string     `json:"snapshot_id" gorm:"column:snapshot_id"`
	NodeID      string     `json:"node_id" gorm:"column:node_id"`
	NodeIP      string     `json:"node_ip" gorm:"column:node_ip"`
	MemoryVol   string     `json:"memory_vol" gorm:"column:memory_vol"`
	RootfsVol   string     `json:"rootfs_vol" gorm:"column:rootfs_vol"`
	SandboxGen  uint32     `json:"sandbox_gen" gorm:"column:sandbox_gen"`
	AttachedAt  time.Time  `json:"attached_at" gorm:"column:attached_at"`
	LastSeenAt  *time.Time `json:"last_seen_at" gorm:"column:last_seen_at"`
	LastError   string     `json:"last_error" gorm:"column:last_error"`
	CreatedAt   time.Time  `json:"created_at" gorm:"column:created_at"`
	UpdatedAt   time.Time  `json:"updated_at" gorm:"column:updated_at"`
}

func (SnapshotRuntimeActive) TableName

func (SnapshotRuntimeActive) TableName() string

type SnapshotRuntimeRef

type SnapshotRuntimeRef struct {
	gorm.Model
	SnapshotID  string     `json:"snapshot_id" gorm:"column:snapshot_id"`
	SandboxID   string     `json:"sandbox_id" gorm:"column:sandbox_id"`
	NodeID      string     `json:"node_id" gorm:"column:node_id"`
	NodeIP      string     `json:"node_ip" gorm:"column:node_ip"`
	BindingType string     `json:"binding_type" gorm:"column:binding_type"`
	MemoryVol   string     `json:"memory_vol" gorm:"column:memory_vol"`
	MemoryDev   string     `json:"memory_dev" gorm:"column:memory_dev"`
	RootfsVol   string     `json:"rootfs_vol" gorm:"column:rootfs_vol"`
	SandboxGen  uint32     `json:"sandbox_gen" gorm:"column:sandbox_gen"`
	Status      string     `json:"status" gorm:"column:status"`
	AttachedAt  time.Time  `json:"attached_at" gorm:"column:attached_at"`
	ReleasedAt  *time.Time `json:"released_at" gorm:"column:released_at"`
	LastSeenAt  *time.Time `json:"last_seen_at" gorm:"column:last_seen_at"`
	LastError   string     `json:"last_error" gorm:"column:last_error"`
}

func (SnapshotRuntimeRef) TableName

func (SnapshotRuntimeRef) TableName() string

type TemplateDefinition

type TemplateDefinition struct {
	gorm.Model
	TemplateID                string `json:"template_id" gorm:"column:template_id"`
	InstanceType              string `json:"instance_type" gorm:"column:instance_type"`
	Version                   string `json:"version" gorm:"column:version"`
	Status                    string `json:"status" gorm:"column:status"`
	Kind                      string `json:"kind" gorm:"column:kind"`
	OriginSandboxID           string `json:"origin_sandbox_id" gorm:"column:origin_sandbox_id"`
	OriginNodeID              string `json:"origin_node_id" gorm:"column:origin_node_id"`
	DisplayName               string `json:"display_name" gorm:"column:display_name"`
	StorageBackend            string `json:"storage_backend" gorm:"column:storage_backend"`
	Retain                    bool   `json:"retain" gorm:"column:retain"`
	RootfsSizeBytesAtSnapshot uint64 `json:"rootfs_size_bytes_at_snapshot" gorm:"column:rootfs_size_bytes_at_snapshot"`
	RootfsArtifactID          string `json:"rootfs_artifact_id" gorm:"column:rootfs_artifact_id"`
	OriginHostFactsJSON       string `json:"origin_host_facts_json" gorm:"column:origin_host_facts_json"`
	RequestJSON               string `json:"request_json" gorm:"column:request_json"`
	LastError                 string `json:"last_error" gorm:"column:last_error"`
}

func (TemplateDefinition) TableName

func (TemplateDefinition) TableName() string

type TemplateImageJob

type TemplateImageJob struct {
	gorm.Model
	JobID                   string `json:"job_id" gorm:"column:job_id"`
	TemplateID              string `json:"template_id" gorm:"column:template_id"`
	RequestID               string `json:"request_id" gorm:"column:request_id"`
	SandboxID               string `json:"sandbox_id" gorm:"column:sandbox_id"`
	ResourceType            string `json:"resource_type" gorm:"column:resource_type"`
	ResourceID              string `json:"resource_id" gorm:"column:resource_id"`
	AttemptNo               int32  `json:"attempt_no" gorm:"column:attempt_no"`
	RetryOfJobID            string `json:"retry_of_job_id" gorm:"column:retry_of_job_id"`
	Operation               string `json:"operation" gorm:"column:operation"`
	RedoMode                string `json:"redo_mode" gorm:"column:redo_mode"`
	RedoScopeJSON           string `json:"redo_scope_json" gorm:"column:redo_scope_json"`
	ResumePhase             string `json:"resume_phase" gorm:"column:resume_phase"`
	NodeID                  string `json:"node_id" gorm:"column:node_id"`
	NodeIP                  string `json:"node_ip" gorm:"column:node_ip"`
	SnapshotPath            string `json:"snapshot_path" gorm:"column:snapshot_path"`
	ArtifactID              string `json:"artifact_id" gorm:"column:artifact_id"`
	TemplateSpecFingerprint string `json:"template_spec_fingerprint" gorm:"column:template_spec_fingerprint"`
	SourceImageRef          string `json:"source_image_ref" gorm:"column:source_image_ref"`
	SourceImageDigest       string `json:"source_image_digest" gorm:"column:source_image_digest"`
	WritableLayerSize       string `json:"writable_layer_size" gorm:"column:writable_layer_size"`
	InstanceType            string `json:"instance_type" gorm:"column:instance_type"`
	NetworkType             string `json:"network_type" gorm:"column:network_type"`
	Status                  string `json:"status" gorm:"column:status"`
	Phase                   string `json:"phase" gorm:"column:phase"`
	Progress                int32  `json:"progress" gorm:"column:progress"`
	ErrorMessage            string `json:"error_message" gorm:"column:error_message"`
	ExpectedNodeCount       int32  `json:"expected_node_count" gorm:"column:expected_node_count"`
	ReadyNodeCount          int32  `json:"ready_node_count" gorm:"column:ready_node_count"`
	FailedNodeCount         int32  `json:"failed_node_count" gorm:"column:failed_node_count"`
	TemplateStatus          string `json:"template_status" gorm:"column:template_status"`
	ArtifactStatus          string `json:"artifact_status" gorm:"column:artifact_status"`
	PullTotalBytes          int64  `json:"pull_total_bytes" gorm:"column:pull_total_bytes"`
	PullDownloadedBytes     int64  `json:"pull_downloaded_bytes" gorm:"column:pull_downloaded_bytes"`
	PullTotalLayers         int32  `json:"pull_total_layers" gorm:"column:pull_total_layers"`
	PullCompletedLayers     int32  `json:"pull_completed_layers" gorm:"column:pull_completed_layers"`
	PullSpeedBPS            int64  `json:"pull_speed_bps" gorm:"column:pull_speed_bps"`
	RequestJSON             string `json:"request_json" gorm:"column:request_json"`
	ResultJSON              string `json:"result_json" gorm:"column:result_json"`
}

func (TemplateImageJob) TableName

func (TemplateImageJob) TableName() string

type TemplateReplica

type TemplateReplica struct {
	gorm.Model
	TemplateID        string `json:"template_id" gorm:"column:template_id"`
	NodeID            string `json:"node_id" gorm:"column:node_id"`
	NodeIP            string `json:"node_ip" gorm:"column:node_ip"`
	InstanceType      string `json:"instance_type" gorm:"column:instance_type"`
	Spec              string `json:"spec" gorm:"column:spec"`
	Status            string `json:"status" gorm:"column:status"`
	Phase             string `json:"phase" gorm:"column:phase"`
	ArtifactID        string `json:"artifact_id" gorm:"column:artifact_id"`
	LastJobID         string `json:"last_job_id" gorm:"column:last_job_id"`
	LastErrorPhase    string `json:"last_error_phase" gorm:"column:last_error_phase"`
	CleanupRequired   bool   `json:"cleanup_required" gorm:"column:cleanup_required"`
	ErrorMessage      string `json:"error_message" gorm:"column:error_message"`
	GuestImageVersion string `json:"guest_image_version" gorm:"column:guest_image_version"`
	AgentVersion      string `json:"agent_version" gorm:"column:agent_version"`
	KernelVersion     string `json:"kernel_version" gorm:"column:kernel_version"`
	ShimVersion       string `json:"shim_version" gorm:"column:shim_version"`
	CompatStatus      string `json:"compat_status" gorm:"column:compat_status"`
	CompatPolicy      string `json:"compat_policy" gorm:"column:compat_policy"`
	CompatCheckedUnix int64  `json:"compat_checked_unix" gorm:"column:compat_checked_unix"`
}

TemplateReplica is the master-side row that tracks where a template definition has been materialized. v5: physical columns (snapshot_path, rootfs_vol, memory_vol, rootfs_kind, memory_kind, rootfs_dev, memory_dev, meta_dir, build_rootfs_vol) were removed from both the struct and the DB schema (see migrations). Cubelet's local snapshot catalog is the single source of truth for physical layout, keyed by templateID/snapshotID.

func (TemplateReplica) TableName

func (TemplateReplica) TableName() string

type VolumeRecord

type VolumeRecord struct {
	ID        uint      `gorm:"primaryKey"`
	CreatedAt time.Time `gorm:"column:created_at"`
	UpdatedAt time.Time `gorm:"column:updated_at"`
	VolumeID  string    `gorm:"column:volume_id;uniqueIndex:uniq_volume_id;not null;size:128"`
	Name      string    `gorm:"column:name;uniqueIndex:uniq_volume_name;not null;default:'';size:128"`
	Driver    string    `gorm:"column:driver;not null;default:''"`
	Token     string    `gorm:"column:token;not null;default:''"`
	// PrivateData is opaque plugin state returned by Create (max 1024 bytes).
	// CubeMaster stores it and forwards it to the Node Attach hook on sandbox
	// create. It is not exposed on the Volume HTTP/SDK response.
	PrivateData string `gorm:"column:private_data;not null;default:'';size:1024"`
	// RefCount tracks how many nodes currently have the volume attached
	// (mounted by at least one sandbox). It is maintained from the node-level
	// 0→1 / 1→0 transitions Cubelet reports on sandbox create/destroy. A volume
	// with RefCount > 0 must not be deleted.
	RefCount int64 `gorm:"column:refcount;not null;default:0"`
}

VolumeRecord persists a single managed volume.

Field layout:

  • VolumeID : stable business key (same as Name when the caller supplies a name)
  • Name : human-readable label; UNIQUE, cannot be reused while the row exists
  • Driver : plugin name (ControllerPlugin.Name()) used to create the volume
  • Token : per-volume credential returned by the plugin; may be empty
  • PrivateData : opaque plugin state from Create; forwarded to Attach; not API-visible
  • RefCount : number of nodes currently referencing (mounting) the volume

Deletion is hard-delete (row removed). There is no deleted_at column.

func (VolumeRecord) TableName

func (VolumeRecord) TableName() string

TableName implements schema.Tabler so GORM uses the canonical table name.

Jump to

Keyboard shortcuts

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