diff --git a/service/lib/agama/storage/config.rb b/service/lib/agama/storage/config.rb index ba825041d9..159a926ba5 100644 --- a/service/lib/agama/storage/config.rb +++ b/service/lib/agama/storage/config.rb @@ -64,7 +64,7 @@ def initialize def boot_device return unless boot.configure? && boot.device.device_alias - drives.find { |d| d.alias?(boot.device.device_alias) } + supporting_partitions.find { |d| d.alias?(boot.device.device_alias) } end # Drive config containing root. diff --git a/service/lib/agama/storage/config_checkers/boot.rb b/service/lib/agama/storage/config_checkers/boot.rb index 383ea756d2..4d25a2fe71 100644 --- a/service/lib/agama/storage/config_checkers/boot.rb +++ b/service/lib/agama/storage/config_checkers/boot.rb @@ -92,7 +92,7 @@ def invalid_alias_issue def valid_alias? return false unless device_alias - storage_config.drives.any? { |d| d.alias?(device_alias) } + storage_config.supporting_partitions.any? { |d| d.alias?(device_alias) } end end end diff --git a/service/package/rubygem-agama-yast.changes b/service/package/rubygem-agama-yast.changes index 1b5c816b25..9ad89f7c22 100644 --- a/service/package/rubygem-agama-yast.changes +++ b/service/package/rubygem-agama-yast.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri May 23 09:27:04 UTC 2025 - Ancor Gonzalez Sosa + +- Allow to specify a software RAID (mdRaids) as explicit boot + device (gh#agama-project/agama#2386). + ------------------------------------------------------------------- Thu May 22 17:21:24 UTC 2025 - Ancor Gonzalez Sosa diff --git a/service/test/agama/storage/config_checkers/boot_test.rb b/service/test/agama/storage/config_checkers/boot_test.rb index b23f3835f4..a59c348f62 100644 --- a/service/test/agama/storage/config_checkers/boot_test.rb +++ b/service/test/agama/storage/config_checkers/boot_test.rb @@ -29,17 +29,20 @@ let(:config_json) do { - boot: { + boot: { configure: configure, device: device_alias }, - drives: [ + drives: [ { alias: "disk", partitions: [ { alias: "p1" } ] } + ], + mdRaids: [ + { alias: "raid" } ] } end @@ -77,9 +80,12 @@ include_examples "alias issue" end - context "and the device with the given alias is not a drive" do - let(:device_alias) { "p1" } - include_examples "alias issue" + context "and the device with the given alias is an mdRaid" do + let(:device_alias) { "raid" } + + it "does not include any issue" do + expect(subject.issues).to be_empty + end end context "and the device with the given alias is a drive" do @@ -89,6 +95,11 @@ expect(subject.issues).to be_empty end end + + context "and the device with the given alias is neither a drive or an mdRaid" do + let(:device_alias) { "p1" } + include_examples "alias issue" + end end context "if boot is not enabled" do diff --git a/service/test/agama/storage/config_test.rb b/service/test/agama/storage/config_test.rb index a2c85cc64d..967271b7dd 100644 --- a/service/test/agama/storage/config_test.rb +++ b/service/test/agama/storage/config_test.rb @@ -54,17 +54,20 @@ context "if boot config is set to be configured" do let(:config_json) do { - boot: { + boot: { configure: true, device: device_alias }, - drives: [ + drives: [ { alias: "disk1", partitions: [ { alias: "part1" } ] } + ], + mdRaids: [ + { alias: "raid1" } ] } end @@ -78,14 +81,6 @@ end context "and boot config has a device alias" do - context "and there is not a drive config with the boot device alias" do - let(:device_alias) { "part1" } - - it "returns nil" do - expect(subject.boot_device).to be_nil - end - end - context "and there is a drive config with the boot device alias" do let(:device_alias) { "disk1" } @@ -94,6 +89,23 @@ expect(subject.boot_device.alias).to eq("disk1") end end + + context "and there is an mdRaid config with the boot device alias" do + let(:device_alias) { "raid1" } + + it "returns the mdRaid config" do + expect(subject.boot_device).to be_a(Agama::Storage::Configs::MdRaid) + expect(subject.boot_device.alias).to eq("raid1") + end + end + + context "and there is not a drive or mdRaid config with the boot device alias" do + let(:device_alias) { "part1" } + + it "returns nil" do + expect(subject.boot_device).to be_nil + end + end end end end diff --git a/service/test/y2storage/agama_proposal_md_test.rb b/service/test/y2storage/agama_proposal_md_test.rb index a67621e15b..4e063fe39b 100644 --- a/service/test/y2storage/agama_proposal_md_test.rb +++ b/service/test/y2storage/agama_proposal_md_test.rb @@ -342,5 +342,35 @@ expect(partition.sid).to eq part_sid end end + + context "when configuring explicit boot from an existing RAID" do + let(:scenario) { "partitioned_md.yml" } + + let(:config_json) do + { + mdRaids: [ + { + search: { max: 1 }, + alias: "raid", + partitions: [ + { search: "*", delete: true }, + { filesystem: { path: "/" } } + ] + } + ], + boot: { configure: true, device: "raid" } + } + end + + it "allocates the boot partition in the RAID" do + md_sid = Y2Storage::StorageManager.instance.probed.find_by_name("/dev/md0").sid + proposal.propose + + md = proposal.devices.find_by_name("/dev/md0") + expect(md.sid).to eq md_sid + expect(md.partitions.size).to eq 2 + expect(md.partitions.first.id).to eq Y2Storage::PartitionId::BIOS_BOOT + end + end end end