Skip to content

Commit

Permalink
db tables for adding sleds
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjstone committed Nov 18, 2023
1 parent 621a7a3 commit 8a6db09
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 2 deletions.
44 changes: 44 additions & 0 deletions schema/crdb/11.0.0/up1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
-- Table of all sled subnets allocated for sleds added to an already initialized
-- rack. The sleds in this table and their allocated subnets are created before
-- a sled is added to the `sled` table. Addition to the `sled` table occurs
-- after the sled is initialized and notifies Nexus about itself.
--
-- For simplicity and space savings, this table doesn't actually contain the
-- full subnets for a given sled, but only the octet that extends a /56 rack
-- subnet to a /64 sled subnet. The rack subnet is maintained in the `rack`
-- table.
--
-- This table does not include subnet octets allocated during RSS and therefore
-- all of the octets start at 33. This makes the data in this table purely additive
-- post-RSS, which also implies that we cannot re-use subnet octets if an original
-- sled that was part of RSS was removed from the cluster.
--
-- All modifications to this table should be guarded by the
-- `reconfiguration_epoch` row in the `rack` table.
CREATE TABLE IF NOT EXISTS omicron.public.sled_underlay_subnet_allocations {
-- The rack to which a sled is being added
-- (foreign key into `rack` table)
--
-- We require this because the sled is not yet part of the sled table when
-- we first allocate a subnet for it.
rack_id UUID NOT NULL

-- The sled to which a subnet is being allocated
--
-- Eventually will be a foreign key into the `sled` table when the sled notifies nexus
-- about itself after initialization.
sled_id UUID NOT NULL,

-- The octet that extends a /56 rack subnet to a /64 sled subnet
--
-- Always between 33 and 255 inclusive
subnet_octet INT2 NOT NULL UNIQUE,

-- The physical identity of the sled
-- (foreign key into `hw_baseboard_id` table)
hw_baseboard_id UUID NOT NULL UNIQUE,

-- Each update will grab all allocations for a rack to figure out what
-- subnet octets are free
PRIMARY KEY (rack_id, sled_id)
};
1 change: 1 addition & 0 deletions schema/crdb/11.0.0/up2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE omicron.public.rack ADD COLUMN IF NOT EXISTS reconfiguration_epoch INT8 NOT NULL DEFAULT 0;
56 changes: 54 additions & 2 deletions schema/crdb/dbinit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ CREATE TABLE IF NOT EXISTS omicron.public.rack (
tuf_base_url STRING(512),

/* The IPv6 underlay /56 prefix for the rack */
rack_subnet INET
rack_subnet INET,

/* A generation number to allow conditional updates and optimisitic
* concurrency control when performing rack cluster reconfigurations, such
* as adding or removing sleds.
*/
reconfiguration_epoch INT8 NOT NULL DEFAULT 0
);

/*
Expand Down Expand Up @@ -158,6 +164,52 @@ CREATE UNIQUE INDEX IF NOT EXISTS lookup_resource_by_sled ON omicron.public.sled
id
);


-- Table of all sled subnets allocated for sleds added to an already initialized
-- rack. The sleds in this table and their allocated subnets are created before
-- a sled is added to the `sled` table. Addition to the `sled` table occurs
-- after the sled is initialized and notifies Nexus about itself.
--
-- For simplicity and space savings, this table doesn't actually contain the
-- full subnets for a given sled, but only the octet that extends a /56 rack
-- subnet to a /64 sled subnet. The rack subnet is maintained in the `rack`
-- table.
--
-- This table does not include subnet octets allocated during RSS and therefore
-- all of the octets start at 33. This makes the data in this table purely additive
-- post-RSS, which also implies that we cannot re-use subnet octets if an original
-- sled that was part of RSS was removed from the cluster.
--
-- All modifications to this table should be guarded by the
-- `reconfiguration_epoch` row in the `rack` table.
CREATE TABLE IF NOT EXISTS omicron.public.sled_underlay_subnet_allocations {
-- The rack to which a sled is being added
-- (foreign key into `rack` table)
--
-- We require this because the sled is not yet part of the sled table when
-- we first allocate a subnet for it.
rack_id UUID NOT NULL

-- The sled to which a subnet is being allocated
--
-- Eventually will be a foreign key into the `sled` table when the sled notifies nexus
-- about itself after initialization.
sled_id UUID NOT NULL,

-- The octet that extends a /56 rack subnet to a /64 sled subnet
--
-- Always between 33 and 255 inclusive
subnet_octet INT2 NOT NULL UNIQUE,

-- The physical identity of the sled
-- (foreign key into `hw_baseboard_id` table)
hw_baseboard_id UUID NOT NULL UNIQUE,

-- Each update will grab all allocations for a rack to figure out what
-- subnet octets are free
PRIMARY KEY (rack_id, sled_id)
};

/*
* Switches
*/
Expand Down Expand Up @@ -2838,7 +2890,7 @@ INSERT INTO omicron.public.db_metadata (
version,
target_version
) VALUES
( TRUE, NOW(), NOW(), '10.0.0', NULL)
( TRUE, NOW(), NOW(), '11.0.0', NULL)
ON CONFLICT DO NOTHING;

COMMIT;

0 comments on commit 8a6db09

Please sign in to comment.