|
|
|
|
@ -147,6 +147,70 @@ CREATE TABLE cloud_host_network_attachments (
|
|
|
|
|
KEY cloud_network_attachment_sync (sync_state, updated_at, id)
|
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
|
|
|
|
|
|
-- A host's existing private underlay remains operator-owned. The panel stores
|
|
|
|
|
-- only the selected address/interface and desired generation; the Agent
|
|
|
|
|
-- verifies the binding and applies tenant VPC routes without configuring the
|
|
|
|
|
-- physical address, bridge or upstream gateway itself.
|
|
|
|
|
CREATE TABLE cloud_host_vpc_transports (
|
|
|
|
|
host_id BIGINT UNSIGNED NOT NULL PRIMARY KEY,
|
|
|
|
|
transport_address VARCHAR(15) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
transport_prefix_length TINYINT UNSIGNED NOT NULL,
|
|
|
|
|
transport_interface VARCHAR(15) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
transport_mode VARCHAR(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT 'direct_l3',
|
|
|
|
|
mtu SMALLINT UNSIGNED NOT NULL DEFAULT 1500,
|
|
|
|
|
desired_revision BIGINT UNSIGNED NOT NULL DEFAULT 1,
|
|
|
|
|
observed_revision BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
sync_state VARCHAR(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT 'never',
|
|
|
|
|
last_operation_id CHAR(32) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,
|
|
|
|
|
last_error_code VARCHAR(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT '',
|
|
|
|
|
last_verified_at BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
created_at BIGINT UNSIGNED NOT NULL,
|
|
|
|
|
updated_at BIGINT UNSIGNED NOT NULL,
|
|
|
|
|
UNIQUE KEY cloud_host_vpc_transport_operation (last_operation_id),
|
|
|
|
|
KEY cloud_host_vpc_transport_state (sync_state, updated_at, host_id),
|
|
|
|
|
CONSTRAINT chk_cloud_host_vpc_transport_prefix CHECK (
|
|
|
|
|
transport_prefix_length BETWEEN 1 AND 32
|
|
|
|
|
),
|
|
|
|
|
CONSTRAINT chk_cloud_host_vpc_transport_mode CHECK (
|
|
|
|
|
transport_mode = 'direct_l3'
|
|
|
|
|
),
|
|
|
|
|
CONSTRAINT chk_cloud_host_vpc_transport_mtu CHECK (
|
|
|
|
|
mtu BETWEEN 576 AND 9216
|
|
|
|
|
),
|
|
|
|
|
CONSTRAINT chk_cloud_host_vpc_transport_state CHECK (
|
|
|
|
|
sync_state IN ('never','pending','applying','ready','failed','unknown')
|
|
|
|
|
),
|
|
|
|
|
CONSTRAINT chk_cloud_host_vpc_transport_revision CHECK (
|
|
|
|
|
observed_revision <= desired_revision
|
|
|
|
|
)
|
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
|
|
|
|
|
|
-- Region-scoped IPv4 supernets are the only source of tenant VPC CIDRs. The
|
|
|
|
|
-- application locks one pool row while selecting a free child prefix, so
|
|
|
|
|
-- concurrent VPC creation cannot allocate overlapping networks.
|
|
|
|
|
CREATE TABLE cloud_vpc_cidr_pools (
|
|
|
|
|
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
|
pool_key CHAR(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
region_id BIGINT UNSIGNED NOT NULL,
|
|
|
|
|
name VARCHAR(80) NOT NULL,
|
|
|
|
|
cidr VARCHAR(18) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
prefix_length TINYINT UNSIGNED NOT NULL,
|
|
|
|
|
allocation_prefix TINYINT UNSIGNED NOT NULL DEFAULT 24,
|
|
|
|
|
state VARCHAR(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT 'active',
|
|
|
|
|
created_at BIGINT UNSIGNED NOT NULL,
|
|
|
|
|
updated_at BIGINT UNSIGNED NOT NULL,
|
|
|
|
|
UNIQUE KEY cloud_vpc_cidr_pool_key (pool_key),
|
|
|
|
|
UNIQUE KEY cloud_vpc_cidr_pool_region (region_id, cidr),
|
|
|
|
|
KEY cloud_vpc_cidr_pool_catalog (region_id, state, id),
|
|
|
|
|
CONSTRAINT chk_cloud_vpc_cidr_pool_prefix CHECK (
|
|
|
|
|
prefix_length BETWEEN 8 AND 28
|
|
|
|
|
AND allocation_prefix BETWEEN prefix_length AND 28
|
|
|
|
|
),
|
|
|
|
|
CONSTRAINT chk_cloud_vpc_cidr_pool_state CHECK (
|
|
|
|
|
state IN ('active','disabled')
|
|
|
|
|
)
|
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
|
|
|
|
|
|
-- A public pool is an allocation boundary, not a compute resource pool. The
|
|
|
|
|
-- child cloud_public_ips rows remain the authoritative concrete-address
|
|
|
|
|
-- ledger used by payment-time placement and reconciliation.
|
|
|
|
|
@ -406,6 +470,115 @@ CREATE TABLE cloud_instances (
|
|
|
|
|
KEY cloud_instance_placement (resource_pool_id, host_id, status),
|
|
|
|
|
KEY cloud_instance_lifecycle (service_status, expires_at, id)
|
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
|
|
|
|
|
|
-- One user-owned L3 VPC belongs to exactly one commercial region. V1 assigns
|
|
|
|
|
-- non-overlapping IPv4 prefixes from a region pool and exposes no cross-region
|
|
|
|
|
-- peering, NAT or L2 broadcast contract.
|
|
|
|
|
CREATE TABLE cloud_vpcs (
|
|
|
|
|
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
|
vpc_key CHAR(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
user_id BIGINT UNSIGNED NOT NULL,
|
|
|
|
|
region_id BIGINT UNSIGNED NOT NULL,
|
|
|
|
|
cidr_pool_id BIGINT UNSIGNED NOT NULL,
|
|
|
|
|
name VARCHAR(80) NOT NULL,
|
|
|
|
|
cidr VARCHAR(18) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
prefix_length TINYINT UNSIGNED NOT NULL,
|
|
|
|
|
gateway VARCHAR(15) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
state VARCHAR(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT 'provisioning',
|
|
|
|
|
desired_revision BIGINT UNSIGNED NOT NULL DEFAULT 1,
|
|
|
|
|
deleted_at BIGINT UNSIGNED DEFAULT NULL,
|
|
|
|
|
created_at BIGINT UNSIGNED NOT NULL,
|
|
|
|
|
updated_at BIGINT UNSIGNED NOT NULL,
|
|
|
|
|
UNIQUE KEY cloud_vpc_key (vpc_key),
|
|
|
|
|
UNIQUE KEY cloud_vpc_region_cidr (region_id, cidr),
|
|
|
|
|
KEY cloud_vpc_owner (user_id, state, id),
|
|
|
|
|
KEY cloud_vpc_region_state (region_id, state, id),
|
|
|
|
|
KEY cloud_vpc_pool_state (cidr_pool_id, state, id),
|
|
|
|
|
CONSTRAINT chk_cloud_vpc_prefix CHECK (
|
|
|
|
|
prefix_length BETWEEN 16 AND 28
|
|
|
|
|
),
|
|
|
|
|
CONSTRAINT chk_cloud_vpc_state CHECK (
|
|
|
|
|
state IN ('provisioning','active','degraded','deleting','deleted')
|
|
|
|
|
),
|
|
|
|
|
CONSTRAINT chk_cloud_vpc_deleted_at CHECK (
|
|
|
|
|
(state = 'deleted' AND deleted_at IS NOT NULL)
|
|
|
|
|
OR (state <> 'deleted' AND deleted_at IS NULL)
|
|
|
|
|
)
|
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
|
|
|
|
|
|
-- VPC ports retain an immutable allocation audit. active_claim is set to NULL
|
|
|
|
|
-- only after every affected Agent has confirmed removal; MySQL then permits a
|
|
|
|
|
-- later port to reuse the released instance/IP while keeping the old row.
|
|
|
|
|
CREATE TABLE cloud_vpc_ports (
|
|
|
|
|
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
|
port_key CHAR(32) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
vpc_id BIGINT UNSIGNED NOT NULL,
|
|
|
|
|
instance_id BIGINT UNSIGNED NOT NULL,
|
|
|
|
|
user_id BIGINT UNSIGNED NOT NULL,
|
|
|
|
|
private_ip VARCHAR(15) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
mac_address CHAR(17) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
active_claim TINYINT UNSIGNED DEFAULT 1,
|
|
|
|
|
state VARCHAR(24) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT 'reserved',
|
|
|
|
|
desired_revision BIGINT UNSIGNED NOT NULL DEFAULT 1,
|
|
|
|
|
applied_revision BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
last_operation_id CHAR(32) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,
|
|
|
|
|
last_error_code VARCHAR(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT '',
|
|
|
|
|
attached_at BIGINT UNSIGNED DEFAULT NULL,
|
|
|
|
|
released_at BIGINT UNSIGNED DEFAULT NULL,
|
|
|
|
|
created_at BIGINT UNSIGNED NOT NULL,
|
|
|
|
|
updated_at BIGINT UNSIGNED NOT NULL,
|
|
|
|
|
UNIQUE KEY cloud_vpc_port_key (port_key),
|
|
|
|
|
UNIQUE KEY cloud_vpc_port_ip_claim (vpc_id, private_ip, active_claim),
|
|
|
|
|
UNIQUE KEY cloud_vpc_port_instance_claim (instance_id, active_claim),
|
|
|
|
|
UNIQUE KEY cloud_vpc_port_mac (mac_address),
|
|
|
|
|
UNIQUE KEY cloud_vpc_port_operation (last_operation_id),
|
|
|
|
|
KEY cloud_vpc_port_owner (user_id, state, id),
|
|
|
|
|
KEY cloud_vpc_port_vpc_state (vpc_id, state, id),
|
|
|
|
|
CONSTRAINT chk_cloud_vpc_port_active_claim CHECK (
|
|
|
|
|
active_claim IS NULL OR active_claim = 1
|
|
|
|
|
),
|
|
|
|
|
CONSTRAINT chk_cloud_vpc_port_state CHECK (
|
|
|
|
|
state IN ('reserved','preparing','attached','detaching',
|
|
|
|
|
'release_pending','released')
|
|
|
|
|
),
|
|
|
|
|
CONSTRAINT chk_cloud_vpc_port_release CHECK (
|
|
|
|
|
(state = 'released' AND active_claim IS NULL AND released_at IS NOT NULL)
|
|
|
|
|
OR (state <> 'released' AND active_claim IS NOT NULL
|
|
|
|
|
AND active_claim = 1 AND released_at IS NULL)
|
|
|
|
|
),
|
|
|
|
|
CONSTRAINT chk_cloud_vpc_port_revision CHECK (
|
|
|
|
|
applied_revision <= desired_revision
|
|
|
|
|
)
|
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
|
|
|
|
|
|
-- Per-host desired/applied generations make one VPC reconciliation observable
|
|
|
|
|
-- without turning individual route commands into panel state. Unknown Agent
|
|
|
|
|
-- effects retain the original operation ID until an inspection converges.
|
|
|
|
|
CREATE TABLE cloud_vpc_host_states (
|
|
|
|
|
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
|
vpc_id BIGINT UNSIGNED NOT NULL,
|
|
|
|
|
host_id BIGINT UNSIGNED NOT NULL,
|
|
|
|
|
desired_revision BIGINT UNSIGNED NOT NULL DEFAULT 1,
|
|
|
|
|
applied_revision BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
desired_digest CHAR(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
|
|
|
applied_digest CHAR(64) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,
|
|
|
|
|
sync_state VARCHAR(16) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT 'pending',
|
|
|
|
|
last_operation_id CHAR(32) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,
|
|
|
|
|
last_error_code VARCHAR(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL DEFAULT '',
|
|
|
|
|
last_success_at BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
last_failure_at BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
|
|
|
|
created_at BIGINT UNSIGNED NOT NULL,
|
|
|
|
|
updated_at BIGINT UNSIGNED NOT NULL,
|
|
|
|
|
UNIQUE KEY cloud_vpc_host_identity (vpc_id, host_id),
|
|
|
|
|
UNIQUE KEY cloud_vpc_host_operation (last_operation_id),
|
|
|
|
|
KEY cloud_vpc_host_sync (host_id, sync_state, updated_at, vpc_id),
|
|
|
|
|
CONSTRAINT chk_cloud_vpc_host_state CHECK (
|
|
|
|
|
sync_state IN ('pending','applying','ready','failed','unknown')
|
|
|
|
|
),
|
|
|
|
|
CONSTRAINT chk_cloud_vpc_host_revision CHECK (
|
|
|
|
|
applied_revision <= desired_revision
|
|
|
|
|
)
|
|
|
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
|
-- Desired/applied host-enforced firewall state. The policy row is the current
|
|
|
|
|
-- tenant view, immutable versions retain idempotency/audit evidence, and rules
|
|
|
|
|
-- contain only the typed public DTO (never hypervisor XML or host commands).
|
|
|
|
|
@ -1024,6 +1197,8 @@ CREATE TABLE cloud_jobs (
|
|
|
|
|
backup_id BIGINT UNSIGNED DEFAULT NULL,
|
|
|
|
|
backup_restore_id BIGINT UNSIGNED DEFAULT NULL,
|
|
|
|
|
backup_recovery_id BIGINT UNSIGNED DEFAULT NULL,
|
|
|
|
|
vpc_id BIGINT UNSIGNED DEFAULT NULL,
|
|
|
|
|
vpc_port_id BIGINT UNSIGNED DEFAULT NULL,
|
|
|
|
|
user_id INT NOT NULL,
|
|
|
|
|
host_id BIGINT UNSIGNED DEFAULT NULL,
|
|
|
|
|
kind VARCHAR(32) NOT NULL,
|
|
|
|
|
@ -1139,6 +1314,8 @@ CREATE TABLE cloud_jobs (
|
|
|
|
|
KEY cloud_job_backup (backup_id, id),
|
|
|
|
|
KEY cloud_job_backup_restore (backup_restore_id, id),
|
|
|
|
|
KEY cloud_job_backup_recovery (backup_recovery_id, id),
|
|
|
|
|
KEY cloud_job_vpc (vpc_id, id),
|
|
|
|
|
KEY cloud_job_vpc_port (vpc_port_id, id),
|
|
|
|
|
KEY cloud_job_overview_state (kind, order_id, phase, outcome, terminal_at, created_at),
|
|
|
|
|
KEY cloud_job_owner (user_id, id),
|
|
|
|
|
KEY cloud_job_parent (parent_job_id, id)
|
|
|
|
|
|