Skip to content
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: 1 addition & 1 deletion service/lib/agama/storage/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion service/lib/agama/storage/config_checkers/boot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions service/package/rubygem-agama-yast.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri May 23 09:27:04 UTC 2025 - Ancor Gonzalez Sosa <ancor@suse.com>

- 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 <ancor@suse.com>

Expand Down
21 changes: 16 additions & 5 deletions service/test/agama/storage/config_checkers/boot_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
32 changes: 22 additions & 10 deletions service/test/agama/storage/config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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" }

Expand All @@ -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
Expand Down
30 changes: 30 additions & 0 deletions service/test/y2storage/agama_proposal_md_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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