From b331cea66db88febf0442c8cad6e13ac2f151c25 Mon Sep 17 00:00:00 2001 From: Ancor Gonzalez Sosa Date: Thu, 14 Nov 2024 15:58:08 +0100 Subject: [PATCH] AgamaProposal: fix bug when partitions are searched but not managed --- .../y2storage/proposal/agama_space_maker.rb | 3 +++ .../y2storage/agama_proposal_search_test.rb | 25 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/service/lib/y2storage/proposal/agama_space_maker.rb b/service/lib/y2storage/proposal/agama_space_maker.rb index 7fc75f822..1e44ac77b 100644 --- a/service/lib/y2storage/proposal/agama_space_maker.rb +++ b/service/lib/y2storage/proposal/agama_space_maker.rb @@ -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 diff --git a/service/test/y2storage/agama_proposal_search_test.rb b/service/test/y2storage/agama_proposal_search_test.rb index 3073df83d..c58a2c73a 100644 --- a/service/test/y2storage/agama_proposal_search_test.rb +++ b/service/test/y2storage/agama_proposal_search_test.rb @@ -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