Skip to content

Commit

Permalink
AgamaProposal: fix bug when partitions are searched but not managed
Browse files Browse the repository at this point in the history
  • Loading branch information
ancorgs committed Nov 14, 2024
1 parent 1e7c3b2 commit b331cea
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions service/lib/y2storage/proposal/agama_space_maker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ def resize_actions(config)
# when they are only about growing and not shrinking
min = current_size?(part, :min) ? nil : part.size.min
max = current_size?(part, :max) ? nil : part.size.max
# If both min and max are equal to the current device size, there is nothing to do
next unless min || max

Y2Storage::SpaceActions::Resize.new(part.found_device.name, min_size: min, max_size: max)
end.compact
end
Expand Down
25 changes: 25 additions & 0 deletions service/test/y2storage/agama_proposal_search_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,5 +214,30 @@
end
end
end

context "when searching existing partitions but not specifying any action on them" do
let(:config_json) do
{
boot: { configure: false },
drives: [
{
search: "/dev/vda",
partitions: [
{ search: "*" },
{ size: "20 GiB", filesystem: { path: "/" } }
]
}
]
}
end

# Regression test. In the past the proposal tried to resize some partitions due to the
# search "*" without actions.
it "no partitions are deleted or resized" do
expect_any_instance_of(Y2Storage::Partition).to_not receive(:detect_resize_info)
# There is no way to make 20 GiB fit without resizing or deleting
expect { proposal.propose }.to raise_error(Y2Storage::NoDiskSpaceError)
end
end
end
end

0 comments on commit b331cea

Please sign in to comment.