This is done by: * Adding version information to SPDK files on the host. This includes: * Package installation path: `/opt/spdk` => `/opt/spdk-$version` * Hugetables path: `/home/spdk/hugetables` => * `/home/spdk/hugetables.$version` * Hugetables mount: `home-spdk-hugetable` => * `home-spdk-hugetables.$version` * Service file: `spdk.service` => `spdk-$version.service` * RPC socket: `/home/spdk/spdk.sock` => `/home/spdk/spdk-$version.sock` * Keeping information about the installation about the installation in * the SpdkInstallation table. * Sending the SPDK version to be used with each storage volume data. Since we have legacy servers which don't have the above version information, the code has assumed `LEGACY_SPDK_VERSION` as SPDK version of those installations, which maps the above information to old names and paths. This can be removed after transitioning all servers. Currently we allow at maximum 2 installations per host, which should be enough when upgrading to a new host. == REPL interactions == Specifying an SPDK version when setting up a host: ``` > Prog::Vm::HostNexus.assemble(new_host_ip, ... other params ..., spdk_version: "v23.09") ``` Installing a second SPDK installation on an existing host: ``` > Prog::Storage::SetupSpdk.setup("v23.09-ubi-0.1", start_service: true, allocation_weight: 10) ``` After this there will be two SPDK installations on the host, v23.09 which has weight 100, and the v23.09-ubi-0.1 which has weight 10. So 100/110 of new VMs will use the v23.09, and 10/110 of new VMs will use v23.09-ubi-0.1.
37 lines
1.1 KiB
Ruby
37 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
Sequel.migration do
|
|
change do
|
|
create_table(:spdk_installation) do
|
|
column :id, :uuid, primary_key: true
|
|
column :version, :text, null: false
|
|
column :allocation_weight, :Integer, null: false
|
|
column :created_at, :timestamptz, null: false, default: Sequel.lit("now()")
|
|
foreign_key :vm_host_id, :vm_host, type: :uuid
|
|
unique [:vm_host_id, :version]
|
|
end
|
|
|
|
alter_table(:vm_storage_volume) do
|
|
add_foreign_key :spdk_installation_id, :spdk_installation, type: :uuid, null: true
|
|
end
|
|
|
|
# Reuse corresponding VmHost's UBID as SpdkInstallation UBID and create
|
|
# records for legacy spdk installations on existing hosts.
|
|
run <<~SQL
|
|
INSERT INTO spdk_installation
|
|
SELECT id, 'LEGACY_SPDK_VERSION', 100, now(), id
|
|
FROM vm_host;
|
|
|
|
UPDATE vm_storage_volume
|
|
SET spdk_installation_id = vm_host_id
|
|
FROM vm
|
|
WHERE vm_storage_volume.vm_id = vm.id;
|
|
SQL
|
|
|
|
# Now that every volume has an installation, we can enforce NOT NULL.
|
|
alter_table(:vm_storage_volume) do
|
|
set_column_not_null :spdk_installation_id
|
|
end
|
|
end
|
|
end
|