Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reinstate AlmaLinux images with a different versioning strategy #1613

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ def self.test?
optional :ubicloud_images_blob_storage_certs, string

override :ubuntu_jammy_version, "20240319", string
override :almalinux_9_version, "9.4-20240507", string
override :almalinux_8_version, "8.9-20231128", string
override :github_ubuntu_2204_version, "20240422.1.0", string
override :github_ubuntu_2004_version, "20240422.1.0", string
override :postgres_ubuntu_2204_version, "20240226.1.0", string
Expand Down
4 changes: 3 additions & 1 deletion lib/option.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def self.postgres_locations

BootImage = Struct.new(:name, :display_name)
BootImages = [
["ubuntu-jammy", "Ubuntu Jammy 22.04 LTS"]
["ubuntu-jammy", "Ubuntu Jammy 22.04 LTS"],
["almalinux-9", "AlmaLinux 9"],
["almalinux-8", "AlmaLinux 8"]
].map { |args| BootImage.new(*args) }.freeze

VmSize = Struct.new(:name, :family, :vcpu, :memory, :min_storage_size_gib, :max_storage_size_gib, :storage_size_step_gib, :visible, :gpu) do
Expand Down
16 changes: 12 additions & 4 deletions prog/download_boot_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def default_boot_image_version(image_name)
case image_name
when "ubuntu-jammy"
Config.ubuntu_jammy_version
when "almalinux-9"
Config.almalinux_9_version
when "almalinux-8"
Config.almalinux_8_version
when "github-ubuntu-2204"
Config.github_ubuntu_2204_version
when "github-ubuntu-2004"
Expand All @@ -43,9 +47,12 @@ def url
elsif image_name == "ubuntu-jammy"
arch = (vm_host.arch == "x64") ? "amd64" : "arm64"
"https://cloud-images.ubuntu.com/releases/jammy/release-#{version}/ubuntu-22.04-server-cloudimg-#{arch}.img"
elsif image_name == "almalinux-9.3"
elsif image_name == "almalinux-8"
fail "Only x64 is supported for almalinux-8" unless vm_host.arch == "x64"
"https://repo.almalinux.org/almalinux/8/cloud/x86_64/images/AlmaLinux-8-GenericCloud-#{version}.x86_64.qcow2"
elsif image_name == "almalinux-9"
arch = (vm_host.arch == "x64") ? "x86_64" : "aarch64"
"https://vault.almalinux.org/9.3/cloud/#{arch}/images/AlmaLinux-9-GenericCloud-9.3-#{version}.#{arch}.qcow2"
"https://repo.almalinux.org/almalinux/9/cloud/#{arch}/images/AlmaLinux-9-GenericCloud-#{version}.#{arch}.qcow2"
pykello marked this conversation as resolved.
Show resolved Hide resolved
else
fail "Unknown image name: #{image_name}"
end
Expand All @@ -55,8 +62,9 @@ def sha256_sum
hashes = {
["ubuntu-jammy", "x64", "20240319"] => "304983616fcba6ee1452e9f38993d7d3b8a90e1eb65fb0054d672ce23294d812",
["ubuntu-jammy", "arm64", "20240319"] => "40ea1181447b9395fa03f6f2c405482fe532a348cc46fbb876effcfbbb35336f",
["almalinux-9.3", "x64", "20231113"] => "6bbd060c971fd827a544c7e5e991a7d9e44460a449d2d058a0bb1290dec5a114",
["almalinux-9.3", "arm64", "20231113"] => "a064715bc755346d5a8e1a4c6b1b7abffe4de03f1b0584942d5483ed32aafd67",
["almalinux-8", "x64", "8.9-20231128"] => "a1686bc537bce699b512e3233666f5b8f69ed797ff1ce0af52c17fdc52942621",
["almalinux-9", "x64", "9.4-20240507"] => "bff0885c804c01fff8aac4b70c9ca4f04e8c119f9ee102043838f33e06f58390",
["almalinux-9", "arm64", "9.4-20240507"] => "75b2e68f6aaa41c039274595ff15968201b7201a7f2f03b109af691f2d3687a1",
["github-ubuntu-2204", "x64", "20240422.1.0"] => "8b1b7af6941ce7b8b93d0c20af712e04e8ceedbd673b29fd4fba3406a3ba133c",
["github-ubuntu-2204", "arm64", "20240422.1.0"] => "e14a7176070af022ace0e057a93beaa420602fa331dc67353ea4ce2459344265",
["github-ubuntu-2004", "x64", "20240422.1.0"] => "cf4f3bd4fc43de5804eac32e810101fcfe078aafeb46cb5a34fff8f8f76b360d",
Expand Down
1 change: 1 addition & 0 deletions spec/lib/validation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@
describe "#validate_boot_image" do
it "valid boot image" do
expect { described_class.validate_boot_image("ubuntu-jammy") }.not_to raise_error
expect { described_class.validate_boot_image("almalinux-9") }.not_to raise_error
end

it "invalid boot image" do
Expand Down
26 changes: 20 additions & 6 deletions spec/prog/download_boot_image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
describe "#default_boot_image_version" do
it "returns the version for the default image" do
expect(dbi.default_boot_image_version("ubuntu-jammy")).to eq(Config.ubuntu_jammy_version)
expect(dbi.default_boot_image_version("almalinux-9")).to eq(Config.almalinux_9_version)
expect(dbi.default_boot_image_version("almalinux-8")).to eq(Config.almalinux_8_version)
expect(dbi.default_boot_image_version("github-ubuntu-2204")).to eq(Config.github_ubuntu_2204_version)
expect(dbi.default_boot_image_version("github-ubuntu-2004")).to eq(Config.github_ubuntu_2004_version)
expect(dbi.default_boot_image_version("github-gpu-ubuntu-2204")).to eq(Config.github_gpu_ubuntu_2204_version)
Expand Down Expand Up @@ -72,15 +74,27 @@
expect(dbi.url).to eq("https://cloud-images.ubuntu.com/releases/jammy/release-20240319/ubuntu-22.04-server-cloudimg-arm64.img")
end

it "returns URL for x64 almalinux-9.3 image" do
expect(dbi).to receive(:frame).and_return({"image_name" => "almalinux-9.3", "version" => "20231113"}).at_least(:once)
expect(dbi.url).to eq("https://vault.almalinux.org/9.3/cloud/x86_64/images/AlmaLinux-9-GenericCloud-9.3-20231113.x86_64.qcow2")
it "returns URL for x64 almalinux-9 image" do
expect(dbi).to receive(:frame).and_return({"image_name" => "almalinux-9", "version" => "9.4-20240507"}).at_least(:once)
expect(dbi.url).to eq("https://repo.almalinux.org/almalinux/9/cloud/x86_64/images/AlmaLinux-9-GenericCloud-9.4-20240507.x86_64.qcow2")
end

it "returns URL for arm64 almalinux-9.3 image" do
expect(dbi).to receive(:frame).and_return({"image_name" => "almalinux-9.3", "version" => "20231113"}).at_least(:once)
it "returns URL for x64 almalinux-8 image" do
expect(dbi).to receive(:frame).and_return({"image_name" => "almalinux-8", "version" => "8.9-20231128"}).at_least(:once)
expect(dbi.url).to eq("https://repo.almalinux.org/almalinux/8/cloud/x86_64/images/AlmaLinux-8-GenericCloud-8.9-20231128.x86_64.qcow2")
end

it "crashes when asked for almalinux-8 on arm64" do
expect(dbi).to receive(:frame).and_return({"image_name" => "almalinux-8", "version" => "8.9-20231128"}).at_least(:once)
vm_host.update(arch: "arm64")
expect { dbi.url }.to raise_error RuntimeError, "Only x64 is supported for almalinux-8"
end

it "returns URL for arm64 almalinux-9 image" do
expect(dbi).to receive(:frame).and_return({"image_name" => "almalinux-9", "version" => "9.4-20240507"}).at_least(:once)
vm_host.update(arch: "arm64")
expect(dbi.url).to eq("https://vault.almalinux.org/9.3/cloud/aarch64/images/AlmaLinux-9-GenericCloud-9.3-20231113.aarch64.qcow2")

expect(dbi.url).to eq("https://repo.almalinux.org/almalinux/9/cloud/aarch64/images/AlmaLinux-9-GenericCloud-9.4-20240507.aarch64.qcow2")
end

it "fails if image name is unknown" do
Expand Down
2 changes: 1 addition & 1 deletion spec/routes/api/project/location/vm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
}.to_json

expect(last_response.status).to eq(400)
expect(JSON.parse(last_response.body)["error"]["details"]["boot_image"]).to eq("\"invalid-boot-image\" is not a valid boot image name. Available boot image names are: [\"ubuntu-jammy\"]")
expect(JSON.parse(last_response.body)["error"]["details"]["boot_image"]).to eq("\"invalid-boot-image\" is not a valid boot image name. Available boot image names are: [\"ubuntu-jammy\", \"almalinux-9\", \"almalinux-8\"]")
end

it "invalid vm size" do
Expand Down
Loading