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.
76 lines
2.1 KiB
Ruby
76 lines
2.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "../lib/storage_volume"
|
|
require_relative "../../common/lib/util"
|
|
require "fileutils"
|
|
require "openssl"
|
|
require "base64"
|
|
|
|
return if ENV["RUN_E2E_TESTS"] != "1"
|
|
|
|
RSpec.describe StorageVolume do
|
|
let(:vm) { "vm012345" }
|
|
|
|
before do
|
|
r "sudo adduser #{vm}"
|
|
end
|
|
|
|
after do
|
|
r "sudo userdel --remove #{vm}"
|
|
end
|
|
|
|
describe "#encrypted_storage_volume" do
|
|
let(:key_wrapping_secrets) {
|
|
key_wrapping_algorithm = "aes-256-gcm"
|
|
cipher = OpenSSL::Cipher.new(key_wrapping_algorithm)
|
|
{
|
|
"algorithm" => key_wrapping_algorithm,
|
|
"key" => Base64.encode64(cipher.random_key),
|
|
"init_vector" => Base64.encode64(cipher.random_iv),
|
|
"auth_data" => "Ubicloud-Storage-Auth"
|
|
}
|
|
}
|
|
let(:encrypted_sv) {
|
|
described_class.new(vm, {
|
|
"disk_index" => 0,
|
|
"device_id" => "#{vm}_0",
|
|
"encrypted" => true,
|
|
"size_gib" => 5,
|
|
"image" => nil,
|
|
"spdk_version" => DEFAULT_SPDK_VERSION
|
|
})
|
|
}
|
|
|
|
it "ensures encrypted prep, start, and purge are idempotent" do
|
|
encrypted_sv.prep(key_wrapping_secrets)
|
|
expect { encrypted_sv.prep(key_wrapping_secrets) }.not_to raise_error
|
|
encrypted_sv.start(key_wrapping_secrets)
|
|
expect { encrypted_sv.start(key_wrapping_secrets) }.not_to raise_error
|
|
encrypted_sv.purge_spdk_artifacts
|
|
expect { encrypted_sv.purge_spdk_artifacts }.not_to raise_error
|
|
end
|
|
end
|
|
|
|
describe "#unencrypted_storage_volume" do
|
|
let(:unencrypted_sv) {
|
|
described_class.new(vm, {
|
|
"disk_index" => 1,
|
|
"device_id" => "#{vm}_1",
|
|
"encrypted" => false,
|
|
"size_gib" => 5,
|
|
"image" => nil,
|
|
"spdk_version" => DEFAULT_SPDK_VERSION
|
|
})
|
|
}
|
|
|
|
it "ensures unencrypted prep, start, and purge are idempotent" do
|
|
unencrypted_sv.prep(nil)
|
|
expect { unencrypted_sv.prep(nil) }.not_to raise_error
|
|
unencrypted_sv.start(nil)
|
|
expect { unencrypted_sv.start(nil) }.not_to raise_error
|
|
unencrypted_sv.purge_spdk_artifacts
|
|
expect { unencrypted_sv.purge_spdk_artifacts }.not_to raise_error
|
|
end
|
|
end
|
|
end
|