New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New strategy for SpaceMaker #1337
Conversation
c474623
to
1c2ac96
Compare
1c2ac96
to
8a1beab
Compare
execute_shrink(action, graph, planned_partitions, disk_name) | ||
when SpaceMakerActions::Delete | ||
execute_delete(action, graph) | ||
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NP: I would explicitly check by SpaceMakerActions::Shrink
, and loging/raising an exception in else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fear that would only lead to a line of code not covered by tests. This is quite internal, not something receiving direct input from the caller. I wouldn't expect a SpaceMakerActions::List
to return an action from an unknown type.
def shrink_partition(partition) | ||
target = shrink_size.unlimited? ? DiskSize.zero : partition.size - shrink_size | ||
# Explicitly avoid alignment to keep current behavior (to be reconsidered) | ||
partition.resize(target, align_type: nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it prevent to resize beyond the available free space?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it does. As you can see here for example, we sometimes use the size of the partition as shrink_size
(so target
becomes partition.size - partition.size
).
yast-storage-ng/src/lib/y2storage/proposal/partitions_distribution_calculator.rb
Line 108 in 1a37459
return partition.size |
Even if those cases, everything works as expected. So this is already proven by the existing tests.
# Class to encapsulate all the GuidedProposal settings related to the process of making space | ||
# to allocate the new operating system | ||
class ProposalSpaceSettings | ||
include EqualByInstanceVariables |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just as note, we have the Equatable
mixin for custom comparison: https://github.com/yast/yast-yast2/blob/master/library/general/src/lib/yast2/equatable.rb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, EqualByInstanceVariables
is used for ProposalSettings
. And this class is basically a subset of those settings extracted to a separate object for clarity. So it makes sense to be consistent with the container class and use the same mechanism.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, only mentioning to promote it for other cases :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version bump and changelog?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
❌ Public Jenkins job #464 failed |
Problem
The traditional behavior of
Y2Storage::Proposal::SpaceMaker
is coupled to the options offered by YaST in that regard. Somehow summarized in this screenshot.But for Agama we want to offer other options.
First of all, we want to stop making a difference for partitions of type Windows/Linux/other. The criteria for classifying a partition in one group or the other is not so clear.
On the other hand, we want to make it possible for Agama to specify any of the four modes described at storage_ui.md. That is:
Solution
This adds to the
ProposalSetting
the concept of different strategies for making space.The default strategy is the classic one, now called
auto
and based on the known settingsresize_windows
,windows_delete_mode
,linux_delete_mode
andother_delete_mode
.A new strategy called
bigger_resize
is added. This strategy ignores the settings previously mentioned and works with a explicit list of actions specified in the proposal settings. Thus, the caller is responsible for deciding what to do with each partition or disk (:force_delete
,:delete
or:resize
). Omitted devices are kept without modification. The only decision taken bySpaceMaker
itself is the order in which those actions must be applied while looking for valid layout. As the name of the strategy suggests, it first executes all the:force_delete
actions, then the:resize
ones (sorted by "recoverable size") and finally the:delete
ones.With this solution, all the mentioned Agama modes can be easily implemented.
:force_delete
for all partitions in the affected disks.:resize
for all partitions in the affected disks.Implementation
The pull request is divided into several commits because the code was refactored into small steps before implementing the strategy support at SpaceMaker. Our comprehensive battery of unit tests survived all those reorganizations.
Testing
Added new unit tests.