Skip to content

Commit

Permalink
service: Avoid reading product mount points too early (#1264)
Browse files Browse the repository at this point in the history
## Problem

Changes in #1236 introduced a bug
reading the product mount points.

The list of mount points was read just after selecting a new product. At
that time, the *storage* service has not updated its config yet, so it
still uses the previous product.

Note that the *manager* service calls to storage `#probe` when a new
product is selected, and the *storage* service updates its config as
part of the call to `#probe`. For that reason, the product mount points
cannot be updated until probe is done.

https://bugzilla.suse.com/show_bug.cgi?id=1225348

## Solution

Do not update the product mount points when the product changes. The
list of product mount points is automatically refreshed once the probing
is done.
  • Loading branch information
joseivanlopez authored May 27, 2024
2 parents 208d111 + 79c53c1 commit 9267f32
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
13 changes: 3 additions & 10 deletions service/lib/agama/dbus/storage/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class Manager < BaseObject
def initialize(backend, logger)
super(PATH, logger: logger)
@backend = backend
@product_mount_points = read_product_mount_points
@encryption_methods = read_encryption_methods

register_storage_callbacks
Expand Down Expand Up @@ -122,10 +121,10 @@ def available_devices
proposal.available_devices.map { |d| system_devices_tree.path_for(d) }
end

# Reads the list of meaningful mount points for the current product.
# Meaningful mount points for the current product.
#
# @return [Array<String>]
def read_product_mount_points
def product_mount_points
volume_templates_builder
.all
.map(&:mount_path)
Expand Down Expand Up @@ -178,8 +177,7 @@ def calculate_proposal(dbus_settings)
dbus_interface PROPOSAL_CALCULATOR_INTERFACE do
dbus_reader :available_devices, "ao"

# PropertiesChanged signal if the product changes, see {#register_software_callbacks}.
dbus_reader_attr_accessor :product_mount_points, "as"
dbus_reader :product_mount_points, "as"

# PropertiesChanged signal if software is probed, see {#register_software_callbacks}.
dbus_reader_attr_accessor :encryption_methods, "as"
Expand Down Expand Up @@ -322,11 +320,6 @@ def register_iscsi_callbacks
end

def register_software_callbacks
backend.software.on_product_selected do
# A PropertiesChanged signal is emitted (see ::DBus::Object.dbus_reader_attr_accessor).
self.product_mount_points = read_product_mount_points
end

backend.software.on_probe_finished do
# A PropertiesChanged signal is emitted (see ::DBus::Object.dbus_reader_attr_accessor).
self.encryption_methods = read_encryption_methods
Expand Down
5 changes: 5 additions & 0 deletions service/package/rubygem-agama-yast.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
-------------------------------------------------------------------
Mon May 27 12:43:49 UTC 2024 - José Iván López González <jlopez@suse.com>

- Update product mount points as part of the probing (bsc#1225348).

-------------------------------------------------------------------
Tue May 21 05:32:46 UTC 2024 - José Iván López González <jlopez@suse.com>

Expand Down
4 changes: 1 addition & 3 deletions service/test/agama/dbus/storage/manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@
end

let(:software) do
instance_double(Agama::DBus::Clients::Software,
on_product_selected: nil,
on_probe_finished: nil)
instance_double(Agama::DBus::Clients::Software, on_probe_finished: nil)
end

before do
Expand Down

0 comments on commit 9267f32

Please sign in to comment.