Skip to content

Restore LRTQ DB migration when trust quorum is fully integrated #9538

@andrewjstone

Description

@andrewjstone

In order to upgrade from LRTQ to trust quorum we create an lrtq_members table. We then use that table to feed the first membership group of trust quorum. To create the group in the first place we require a couple of data migrations. These were removed from #9486 because if they run in a release before trust quorum is complete then it's possible the lrtq_members table will contain extra sleds or be missing sleds that should be in the trust quorum. This is because after the migration runs an operator may add or remove sleds.

We therefore only want to run these migrations right before we enable trust quorum in the same upgrade. We need to put the migrations in place when all the other code is in place and trust quorum is enabled. Enablement and adding of this migration should almost certainly happen in the same commit.

The migration code is here for future use:

-- Ensure that each sled always has a `hw_baseboard_id`.
--
-- It would be weird if this wasn't true, but we want to guarantee it before
-- upgrade from LRTQ to TQ.
INSERT INTO omicron.public.hw_baseboard_id
     (id, part_number, serial_number)
 SELECT
     gen_random_uuid(), part_number, serial_number
 FROM omicron.public.sled as sled
 ON CONFLICT DO NOTHING;


-- Put all `hw_baseboard_id`s for non-expunged sleds into `lrtq_members`
INSERT INTO omicron.public.lrtq_members
     (rack_id, hw_baseboard_id)
 SELECT
     sled.rack_id, hw.id
 FROM omicron.public.sled as sled
 INNER JOIN omicron.public.hw_baseboard_id as hw
 ON
   sled.part_number = hw.part_number
   AND sled.serial_number = hw.serial_number
   AND sled.sled_policy != 'expunged'
ON CONFLICT DO NOTHING;

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions