Skip to content

Commit

Permalink
File system and snapshots config (#926)
Browse files Browse the repository at this point in the history
## Problem

The file system type cannot be selected when adding or editing a file
system. The file system is always created with its default file system
type.

*
https://trello.com/c/JnSKpQnu/3418-3-storage-modify-basic-attributes-fstype-snapshots-etc-for-pre-defined-volumes

## Solution

Add a selector for the file system type.

* If the product allows configuring snapshots, then the selector
includes both *Btrfs* and *Btrfs with snapshots* (and the rest of
possible types).
* If there is only an option for the file system type (e.g., *swap*),
then the selector is not offered. A plain text with the unique value is
shown.

Follow-up: #932

## Testing

* Added new unit tests
* Tested manually

## Screenshots

[Screencast from 2023-12-15
14-52-33.webm](https://github.com/openSUSE/agama/assets/1112304/feac328d-8ffd-4485-be5b-997b2aad49b6)
  • Loading branch information
joseivanlopez authored Dec 15, 2023
2 parents 3a787ea + fcc30cb commit 383c9bc
Show file tree
Hide file tree
Showing 12 changed files with 313 additions and 40 deletions.
4 changes: 2 additions & 2 deletions service/lib/agama/storage/volume_outline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class VolumeOutline

# Whether snapshots option can be configured
#
# @return [Boolean]
# @return [Boolean] false by default
attr_accessor :snapshots_configurable
alias_method :snapshots_configurable?, :snapshots_configurable

Expand All @@ -93,7 +93,7 @@ class VolumeOutline
def initialize
@required = false
@adjust_by_ram = false
@snapshots_configurable = true
@snapshots_configurable = false
@filesystems = []
@base_min_size = Y2Storage::DiskSize.zero
@base_max_size = Y2Storage::DiskSize.unlimited
Expand Down
2 changes: 1 addition & 1 deletion service/lib/agama/storage/volume_templates_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def outline(data) # rubocop:disable Metrics/AbcSize
outline.required = fetch(outline_data, "required", false)
outline.filesystems = fetch(outline_data, "filesystems", [])
outline.filesystems.map! { |fs| fs_type(fs) }
outline.snapshots_configurable = fetch(outline_data, "snapshots_configurable", true)
outline.snapshots_configurable = fetch(outline_data, "snapshots_configurable", false)

size = fetch(outline_data, "auto_size", {})
min = parse_disksize(fetch(size, :base_min))
Expand Down
6 changes: 6 additions & 0 deletions service/package/rubygem-agama.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri Dec 15 15:04:43 UTC 2023 - José Iván López González <jlopez@suse.com>

- Set snapshots as not configurable by default
(gh#openSUSE/agama#926).

-------------------------------------------------------------------
Tue Dec 5 09:49:10 UTC 2023 - José Iván López González <jlopez@suse.com>

Expand Down
19 changes: 15 additions & 4 deletions service/test/agama/dbus/storage/manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,21 @@
}
end

let(:config_data) do
{ "storage" => { "volumes" => [], "volume_templates" => cfg_templates } }
end

let(:cfg_templates) do
[
{
"mount_path" => "/",
"outline" => {
"snapshots_configurable" => true
}
}
]
end

it "calculates a proposal with settings having a volume with values from D-Bus" do
expect(proposal).to receive(:calculate) do |settings|
volume = settings.volumes.first
Expand All @@ -355,10 +370,6 @@
context "and the D-Bus volume does not include some values" do
let(:dbus_volume1) { { "MountPath" => "/" } }

let(:config_data) do
{ "storage" => { "volumes" => [], "volume_templates" => cfg_templates } }
end

let(:cfg_templates) do
[
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"Required" => false,
"FsTypes" => [],
"SupportAutoSize" => false,
"SnapshotsConfigurable" => true,
"SnapshotsConfigurable" => false,
"SnapshotsAffectSizes" => false,
"SizeRelevantVolumes" => []
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@
end

let(:outline) do
{ "filesystems" => ["xfs", "ext3", "ext4"] }
{
"filesystems" => ["xfs", "ext3", "ext4"],
"snapshots_configurable" => true
}
end

describe "#convert" do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"Required" => false,
"FsTypes" => [],
"SupportAutoSize" => false,
"SnapshotsConfigurable" => true,
"SnapshotsConfigurable" => false,
"SnapshotsAffectSizes" => false,
"SizeRelevantVolumes" => []
}
Expand Down
6 changes: 6 additions & 0 deletions web/package/cockpit-agama.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri Dec 15 15:03:40 UTC 2023 - José Iván López González <jlopez@suse.com>

- Allow selecting file system type and configure snapshots
(gh#openSUSE/agama/926).

-------------------------------------------------------------------
Sat Dec 2 18:06:02 UTC 2023 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

Expand Down
4 changes: 0 additions & 4 deletions web/src/assets/styles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ li {
svg {
vertical-align: middle;
}

span {
margin-inline-start: var(--spacer-small);
}
}

// Style focus making use of :focus-visible
Expand Down
6 changes: 6 additions & 0 deletions web/src/assets/styles/patternfly-overrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,9 @@ table td > .pf-v5-c-empty-state {
--pf-v5-c-expandable-section__content--PaddingLeft: var(--spacer-normal);
}
}

.pf-v5-c-form__group-label-help {
margin: 0;
padding: 0;
vertical-align: top;
}
Loading

0 comments on commit 383c9bc

Please sign in to comment.