Skip to content

Commit

Permalink
Schemas, expectorate
Browse files Browse the repository at this point in the history
  • Loading branch information
smklein committed Aug 8, 2024
1 parent de22ac0 commit 018f1f7
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 16 deletions.
20 changes: 10 additions & 10 deletions dev-tools/reconfigurator-cli/tests/output/cmd-stdout
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ sled ..........<REDACTED_UUID>...........
subnet fd00:1122:3344:101::/64
zpools (10):
..........<REDACTED_UUID>........... (zpool)
↳ SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
(SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }, [])
..........<REDACTED_UUID>........... (zpool)
↳ SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
(SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }, [])
..........<REDACTED_UUID>........... (zpool)
↳ SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
(SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }, [])
..........<REDACTED_UUID>........... (zpool)
↳ SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
(SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }, [])
..........<REDACTED_UUID>........... (zpool)
↳ SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
(SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }, [])
..........<REDACTED_UUID>........... (zpool)
↳ SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
(SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }, [])
..........<REDACTED_UUID>........... (zpool)
↳ SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
(SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }, [])
..........<REDACTED_UUID>........... (zpool)
↳ SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
(SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }, [])
..........<REDACTED_UUID>........... (zpool)
↳ SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
(SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }, [])
..........<REDACTED_UUID>........... (zpool)
↳ SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
(SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }, [])


> sled-add ..........<REDACTED_UUID>...........
Expand Down
3 changes: 2 additions & 1 deletion nexus/db-model/src/schema_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::collections::BTreeMap;
///
/// This must be updated when you change the database schema. Refer to
/// schema/crdb/README.adoc in the root of this repository for details.
pub const SCHEMA_VERSION: SemverVersion = SemverVersion::new(87, 0, 0);
pub const SCHEMA_VERSION: SemverVersion = SemverVersion::new(88, 0, 0);

/// List of all past database schema versions, in *reverse* order
///
Expand All @@ -29,6 +29,7 @@ static KNOWN_VERSIONS: Lazy<Vec<KnownVersion>> = Lazy::new(|| {
// | leaving the first copy as an example for the next person.
// v
// KnownVersion::new(next_int, "unique-dirname-with-the-sql-files"),
KnownVersion::new(88, "blueprint-dataset"),
KnownVersion::new(87, "inv-dataset"),
KnownVersion::new(86, "dataset-kinds-zone-and-debug"),
KnownVersion::new(85, "add-migrations-by-time-created-index"),
Expand Down
11 changes: 10 additions & 1 deletion nexus/db-queries/tests/output/region_allocate_distinct_sleds.sql
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ WITH
dataset.port,
dataset.kind,
dataset.size_used,
dataset.zone_name
dataset.zone_name,
dataset.quota,
dataset.reservation,
dataset.compression
)
(
SELECT
Expand All @@ -286,6 +289,9 @@ WITH
dataset.kind,
dataset.size_used,
dataset.zone_name,
dataset.quota,
dataset.reservation,
dataset.compression,
old_regions.id,
old_regions.time_created,
old_regions.time_modified,
Expand Down Expand Up @@ -313,6 +319,9 @@ UNION
updated_datasets.kind,
updated_datasets.size_used,
updated_datasets.zone_name,
updated_datasets.quota,
updated_datasets.reservation,
updated_datasets.compression,
inserted_regions.id,
inserted_regions.time_created,
inserted_regions.time_modified,
Expand Down
11 changes: 10 additions & 1 deletion nexus/db-queries/tests/output/region_allocate_random_sleds.sql
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,10 @@ WITH
dataset.port,
dataset.kind,
dataset.size_used,
dataset.zone_name
dataset.zone_name,
dataset.quota,
dataset.reservation,
dataset.compression
)
(
SELECT
Expand All @@ -284,6 +287,9 @@ WITH
dataset.kind,
dataset.size_used,
dataset.zone_name,
dataset.quota,
dataset.reservation,
dataset.compression,
old_regions.id,
old_regions.time_created,
old_regions.time_modified,
Expand Down Expand Up @@ -311,6 +317,9 @@ UNION
updated_datasets.kind,
updated_datasets.size_used,
updated_datasets.zone_name,
updated_datasets.quota,
updated_datasets.reservation,
updated_datasets.compression,
inserted_regions.id,
inserted_regions.time_created,
inserted_regions.time_modified,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,10 @@ WITH
dataset.port,
dataset.kind,
dataset.size_used,
dataset.zone_name
dataset.zone_name,
dataset.quota,
dataset.reservation,
dataset.compression
)
(
SELECT
Expand All @@ -297,6 +300,9 @@ WITH
dataset.kind,
dataset.size_used,
dataset.zone_name,
dataset.quota,
dataset.reservation,
dataset.compression,
old_regions.id,
old_regions.time_created,
old_regions.time_modified,
Expand Down Expand Up @@ -324,6 +330,9 @@ UNION
updated_datasets.kind,
updated_datasets.size_used,
updated_datasets.zone_name,
updated_datasets.quota,
updated_datasets.reservation,
updated_datasets.compression,
inserted_regions.id,
inserted_regions.time_created,
inserted_regions.time_modified,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,10 @@ WITH
dataset.port,
dataset.kind,
dataset.size_used,
dataset.zone_name
dataset.zone_name,
dataset.quota,
dataset.reservation,
dataset.compression
)
(
SELECT
Expand All @@ -295,6 +298,9 @@ WITH
dataset.kind,
dataset.size_used,
dataset.zone_name,
dataset.quota,
dataset.reservation,
dataset.compression,
old_regions.id,
old_regions.time_created,
old_regions.time_modified,
Expand Down Expand Up @@ -322,6 +328,9 @@ UNION
updated_datasets.kind,
updated_datasets.size_used,
updated_datasets.zone_name,
updated_datasets.quota,
updated_datasets.reservation,
updated_datasets.compression,
inserted_regions.id,
inserted_regions.time_created,
inserted_regions.time_modified,
Expand Down
4 changes: 4 additions & 0 deletions schema/crdb/blueprint-dataset/up01.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ALTER TABLE omicron.public.dataset
ADD COLUMN IF NOT EXISTS quota INT8,
ADD COLUMN IF NOT EXISTS reservation INT8,
ADD COLUMN IF NOT EXISTS compression TEXT
4 changes: 4 additions & 0 deletions schema/crdb/blueprint-dataset/up02.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CREATE TYPE IF NOT EXISTS omicron.public.bp_dataset_disposition AS ENUM (
'in_service',
'expunged'
)
9 changes: 9 additions & 0 deletions schema/crdb/blueprint-dataset/up03.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- description of a collection of omicron datasets stored in a blueprint
CREATE TABLE IF NOT EXISTS omicron.public.bp_sled_omicron_datasets (
-- foreign key into the `blueprint` table
blueprint_id UUID NOT NULL,
sled_id UUID NOT NULL,
generation INT8 NOT NULL,

PRIMARY KEY (blueprint_id, sled_id)
)
35 changes: 35 additions & 0 deletions schema/crdb/blueprint-dataset/up04.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
-- description of an omicron dataset specified in a blueprint.
CREATE TABLE IF NOT EXISTS omicron.public.bp_omicron_dataset (
-- foreign key into the `blueprint` table
blueprint_id UUID NOT NULL,
sled_id UUID NOT NULL,
id UUID NOT NULL,

-- Dataset disposition
disposition omicron.public.bp_dataset_disposition NOT NULL,

pool_id UUID NOT NULL,
kind omicron.public.dataset_kind NOT NULL,
-- Only valid if kind = zone
zone_name TEXT,

-- Only valid if kind = crucible
ip INET,
port INT4 CHECK (port BETWEEN 0 AND 65535),

quota INT8,
reservation INT8,
compression TEXT,

CONSTRAINT zone_name_for_zone_kind CHECK (
(kind != 'zone') OR
(kind = 'zone' AND zone_name IS NOT NULL)
),

CONSTRAINT ip_and_port_set_for_crucible CHECK (
(kind != 'crucible') OR
(kind = 'crucible' AND ip IS NOT NULL and port IS NOT NULL)
),

PRIMARY KEY (blueprint_id, id)
)
2 changes: 1 addition & 1 deletion schema/crdb/dbinit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4247,7 +4247,7 @@ INSERT INTO omicron.public.db_metadata (
version,
target_version
) VALUES
(TRUE, NOW(), NOW(), '87.0.0', NULL)
(TRUE, NOW(), NOW(), '88.0.0', NULL)
ON CONFLICT DO NOTHING;

COMMIT;

0 comments on commit 018f1f7

Please sign in to comment.