Skip to content

Commit

Permalink
GuidedProposal: allow Agama to limit automatic adjustments to RAM
Browse files Browse the repository at this point in the history
  • Loading branch information
ancorgs committed Mar 21, 2024
1 parent 927c4d9 commit 0e1b08a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib/y2storage/proposal/devices_planner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ def adjust_sizes(planned_device, volume)
planned_device.min_size = min_size(volume)
planned_device.max_size = max_size(volume)

return if volume.ignore_adjust_by_ram?

if volume.adjust_by_ram?
planned_device.min_size = [planned_device.min_size, ram_size].max
planned_device.max_size = [planned_device.max_size, ram_size].max
Expand Down
7 changes: 7 additions & 0 deletions src/lib/y2storage/volume_specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,16 @@ class VolumeSpecification
# @return [Boolean] true if #snapshots_size and #snapshots_percentage should be ignored
attr_accessor :ignore_snapshots_sizes

# Whether to ignore any possible effect on the size derived from RAM size
#
# @return [Boolean] true if #adjust_by_ram should be ignored
attr_accessor :ignore_adjust_by_ram

alias_method :proposed?, :proposed
alias_method :proposed_configurable?, :proposed_configurable
alias_method :adjust_by_ram?, :adjust_by_ram
alias_method :adjust_by_ram_configurable?, :adjust_by_ram_configurable
alias_method :ignore_adjust_by_ram?, :ignore_adjust_by_ram
alias_method :snapshots?, :snapshots
alias_method :snapshots_configurable?, :snapshots_configurable
alias_method :ignore_snapshots_sizes?, :ignore_snapshots_sizes
Expand Down Expand Up @@ -380,6 +386,7 @@ def apply_defaults
@fs_types = []
@ignore_fallback_sizes = false
@ignore_snapshots_sizes = false
@ignore_adjust_by_ram = false
@reformat = true
end

Expand Down
6 changes: 6 additions & 0 deletions test/y2storage/proposal/devices_planner_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,12 @@
expect(planned_device.min_size).to eq(8.GiB)
expect(planned_device.max_size).to eq(8.GiB)
end

it "does not extend the sizes to ram size if #ignore_adjust_by_ram is set" do
vol_in_settings.ignore_adjust_by_ram = true
expect(planned_device.min_size).to eq(1.GiB)
expect(planned_device.max_size).to eq(2.GiB)
end
end

context "when it is planning a device with btrfs filesystem" do
Expand Down

0 comments on commit 0e1b08a

Please sign in to comment.