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_checkers/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def error(message)

# @return [Issue, nil]
def not_found_issue
return if search.device || search.skip_device?
return if search.device || search.create_device? || search.skip_device?

if search.name
# TRANSLATORS: %s is replaced by a device name (e.g., "/dev/vda").
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 @@
-------------------------------------------------------------------
Mon Mar 23 15:32:40 UTC 2026 - Ancor Gonzalez Sosa <ancor@suse.com>

- Fix overzealous check preventing the usage of ifNotFound:create
in the storage section (fixes gh#agama-project/agama#2985).

-------------------------------------------------------------------
Thu Mar 19 21:12:15 UTC 2026 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

Expand Down
12 changes: 11 additions & 1 deletion service/test/agama/storage/config_checkers/search_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,17 @@
end
end

context "and the device cannot be skipped" do
context "and the device should be created instead" do
before do
config.search.if_not_found = :create
end

it "does not include any issue" do
expect(subject.issues).to be_empty
end
end

context "and the device cannot be skipped or created" do
before do
config.search.if_not_found = :error
end
Expand Down
80 changes: 80 additions & 0 deletions service/test/y2storage/agama_proposal_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,9 @@ def partition_config(name: nil, filesystem: nil, size: nil)
part.search = Agama::Storage::Configs::Search.new.tap do |search|
search.if_not_found = if_not_found
end
part.filesystem = Agama::Storage::Configs::Filesystem.new.tap do |fs|
fs.path = "/foo"
end
end
end

Expand Down Expand Up @@ -594,6 +597,26 @@ def partition_config(name: nil, filesystem: nil, size: nil)
)
end
end

context "if if_not_found is set to :create" do
let(:if_not_found) { :create }

it "calculates a proposal if possible" do
proposal.propose
expect(proposal.failed?).to eq false
end

it "does not register any issue about missing partitions" do
proposal.propose
expect(proposal.issues_list).to be_empty
end

it "creates the missing partition" do
proposal.propose
expect(proposal.devices.partitions.map(&:filesystem))
.to include an_object_having_attributes(mount_path: "/foo")
end
end
end

context "when searching for an existent partition" do
Expand Down Expand Up @@ -1139,6 +1162,63 @@ def partition_config(name: nil, filesystem: nil, size: nil)
end
end

# Regression test for https://github.com/agama-project/agama/issues/2985
context "when searching or creating a partition" do
let(:scenario) { "disks.yaml" }

let(:config_json) do
{
drives: [
{
partitions: [
{
search: {
condition: {
number: partition_nr
},
ifNotFound: :create
},
filesystem: {
path: "/",
type: "ext3"
}
}
]
}
]
}
end

context "if the partition already exists" do
let(:partition_nr) { 3 }

it "reuses the partition" do
vda3_sid = Y2Storage::StorageManager.instance.probed.find_by_name("/dev/vda3").sid

devicegraph = proposal.propose

vda3 = devicegraph.find_device(vda3_sid)
expect(vda3).to_not be_nil
expect(vda3.filesystem.mount_path).to eq("/")
end
end

context "if the partition does not exist" do
let(:partition_nr) { 5 }

it "creates a new partition" do
parts = Y2Storage::StorageManager.instance.probed.find_by_name("/dev/vda").partitions.size

devicegraph = proposal.propose

vda = devicegraph.find_by_name("/dev/vda")
expect(vda.partitions.size).to eq(parts + 1)
expect(vda.partitions.map(&:filesystem))
.to include an_object_having_attributes(mount_path: "/")
end
end
end

context "resizing an existing partition" do
let(:scenario) { "disks.yaml" }

Expand Down
Loading