From f1bf9f33d56cbd98d40c1f70150c246184946a31 Mon Sep 17 00:00:00 2001 From: Ancor Gonzalez Sosa Date: Thu, 14 Nov 2024 15:57:40 +0100 Subject: [PATCH 1/3] AgamaProposal: return the documented exception type --- .../y2storage/proposal/agama_devices_creator.rb | 16 +++++++++++----- service/test/agama/storage/proposal_test.rb | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/service/lib/y2storage/proposal/agama_devices_creator.rb b/service/lib/y2storage/proposal/agama_devices_creator.rb index 98d5b4163f..e81f8e2d11 100644 --- a/service/lib/y2storage/proposal/agama_devices_creator.rb +++ b/service/lib/y2storage/proposal/agama_devices_creator.rb @@ -125,11 +125,17 @@ def process_devices def process_existing_partitionables partitions = partitions_for_existing(planned_devices) - # Check whether there is any chance of getting an unwanted order for the planned partitions - # within a disk - space_result = space_maker.provide_space( - original_graph, partitions: partitions, volume_groups: automatic_vgs - ) + begin + # Check whether there is any chance of getting an unwanted order for the planned + # partitions within a disk + space_result = space_maker.provide_space( + original_graph, partitions: partitions, volume_groups: automatic_vgs + ) + rescue Error => e + log.info "SpaceMaker was not able to find enough space: #{e}" + raise NoDiskSpaceError + end + self.devicegraph = space_result[:devicegraph] distribution = space_result[:partitions_distribution] diff --git a/service/test/agama/storage/proposal_test.rb b/service/test/agama/storage/proposal_test.rb index 5f5b573fd5..2d71168c1a 100644 --- a/service/test/agama/storage/proposal_test.rb +++ b/service/test/agama/storage/proposal_test.rb @@ -580,7 +580,7 @@ def drive(partitions) subject.calculate_agama(config) expect(subject.issues).to include( - an_object_having_attributes(description: /A problem ocurred/) + an_object_having_attributes(description: /Cannot accommodate/) ) end end From cb86f83860d59a2be2612a04107dd56f9c9fdeaa Mon Sep 17 00:00:00 2001 From: Ancor Gonzalez Sosa Date: Thu, 14 Nov 2024 15:58:08 +0100 Subject: [PATCH 2/3] AgamaProposal: fix bug when partitions are searched but not managed --- .../y2storage/proposal/agama_space_maker.rb | 23 +++++++++++------ .../y2storage/agama_proposal_search_test.rb | 25 +++++++++++++++++++ 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/service/lib/y2storage/proposal/agama_space_maker.rb b/service/lib/y2storage/proposal/agama_space_maker.rb index 7fc75f8229..4812940f74 100644 --- a/service/lib/y2storage/proposal/agama_space_maker.rb +++ b/service/lib/y2storage/proposal/agama_space_maker.rb @@ -88,13 +88,22 @@ def delete_actions(config) # @return [Array] def resize_actions(config) partition_configs = partitions(config).select(&:found_device).select(&:size) - partition_configs.map do |part| - # Resize actions contain information that is potentially useful for the SpaceMaker even - # 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 - Y2Storage::SpaceActions::Resize.new(part.found_device.name, min_size: min, max_size: max) - end.compact + # Resize actions contain information that is potentially useful for the SpaceMaker even + # when they are only about growing and not shrinking + partition_configs.map { |p| resize_action(p) }.compact + end + + # @see #resize_actions + # + # @param part [Agama::Storage::Configs::Partition] + # @return [Y2Storage::SpaceActions::Resize, nil] + def resize_action(part) + 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 + return unless min || max + + Y2Storage::SpaceActions::Resize.new(part.found_device.name, min_size: min, max_size: max) end # @see #resize_actions diff --git a/service/test/y2storage/agama_proposal_search_test.rb b/service/test/y2storage/agama_proposal_search_test.rb index 3073df83db..c58a2c73a4 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 From a8d4d87a5052aa473ec759e5c056d411068ee8d3 Mon Sep 17 00:00:00 2001 From: Ancor Gonzalez Sosa Date: Thu, 14 Nov 2024 16:36:28 +0100 Subject: [PATCH 3/3] Changelog update --- service/package/rubygem-agama-yast.changes | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/service/package/rubygem-agama-yast.changes b/service/package/rubygem-agama-yast.changes index f79db1e9d0..28ee900d87 100644 --- a/service/package/rubygem-agama-yast.changes +++ b/service/package/rubygem-agama-yast.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Nov 14 15:34:17 UTC 2024 - Ancor Gonzalez Sosa + +- Storage: fixed bug when existing partitions were searched at the + config but not deleted or resized (gh#agama-project/agama#1767). + ------------------------------------------------------------------- Thu Nov 14 13:26:23 UTC 2024 - Ancor Gonzalez Sosa