From ddbed5a2e9be275876be86650e08bcf494fdcb5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Mon, 16 Feb 2026 16:25:29 +0000 Subject: [PATCH 1/2] Do not deactivate unlisted devices --- service/lib/agama/dbus/storage/dasd.rb | 2 +- service/lib/agama/storage/dasd/manager.rb | 46 +--------- .../test/agama/storage/dasd/manager_test.rb | 85 +------------------ 3 files changed, 4 insertions(+), 129 deletions(-) diff --git a/service/lib/agama/dbus/storage/dasd.rb b/service/lib/agama/dbus/storage/dasd.rb index f588ba0fb5..a8e2c44ba4 100644 --- a/service/lib/agama/dbus/storage/dasd.rb +++ b/service/lib/agama/dbus/storage/dasd.rb @@ -101,7 +101,7 @@ def configure(serialized_config) private - # @return [Agama::Storage::ISCSI::Manager] + # @return [Agama::Storage::DASD::Manager] attr_reader :manager # Performs the configuration process in a separate thread. diff --git a/service/lib/agama/storage/dasd/manager.rb b/service/lib/agama/storage/dasd/manager.rb index c74d5d92b7..a1a7dc7946 100644 --- a/service/lib/agama/storage/dasd/manager.rb +++ b/service/lib/agama/storage/dasd/manager.rb @@ -61,10 +61,6 @@ def initialize(logger: nil) # Keeps whether a configuration was already applied. In some cases it is necessary to # consider that the config has not being applied yet, see {#probe}. @configured = false - # Keeps the list of locked devices. A device is considered as locked if it is active at - # the time of probing. Those devices should not be deactivated when applying a config that - # does not include such devices. - @locked_devices = [] # Keeps the list of formatted devices. A device is added to the list when it was formatted # as effect of applying a config. Those devices should not be formatted anymore when # applying a new config. @@ -88,7 +84,6 @@ def probe @devices = reader.list(force_probing: true) # Initialize the attribute just in case the reader doesn't do it (see bsc#1209162) @devices.each { |d| d.diag_wanted = d.use_diag } - assign_locked_devices(@devices) end # Applies the given DASD config. @@ -106,7 +101,6 @@ def configure(config_json) format_devices(config) enable_diag(config) disable_diag(config) - remove_locked_devices(config) end # Whether the system is already configured for the given config. @@ -169,20 +163,10 @@ def activate_devices(config) # @param config [Config] # @return [Array] Deactivated devices. def deactivate_devices(config) - # Explictly deactivated devices. - deactivated_devices = config.devices + devices = config.devices .reject(&:active?) .map { |d| find_device(d.channel) } .compact - - # Devices that are not included in the config and are not locked. - missing_devices = devices - .reject { |d| device_locked?(d) } - .reject { |d| config.include_device?(d.id) } - - devices = deactivated_devices - .concat(missing_devices) - .uniq .select(&:active?) return [] if devices.empty? @@ -267,34 +251,6 @@ def refresh_devices(devices) devices.each { |d| reader.update_info(d, extended: true) } end - # Sets the list of locked devices. - # - # A device is considered as locked if it is active and not configured yet. - # - # @param devices [Array] - def assign_locked_devices(devices) - config = ConfigImporter.new(config_json || {}).import - @locked_devices = devices - .reject(&:offline?) - .reject { |d| config.include_device?(d.id) } - .map(&:id) - end - - # Removes the given devices from the list of locked devices. - # - # @param config [Config] - def remove_locked_devices(config) - config.devices.each { |d| @locked_devices.delete(d.channel) } - end - - # Whether the given device is locked. - # - # @param device [Y2S390::Dasd] - # @return [Boolean] - def device_locked?(device) - @locked_devices.include?(device.id) - end - # Whether the given device was formatted. # # @param device [Y2S390::Dasd] diff --git a/service/test/agama/storage/dasd/manager_test.rb b/service/test/agama/storage/dasd/manager_test.rb index ed041be517..2c177dcdec 100644 --- a/service/test/agama/storage/dasd/manager_test.rb +++ b/service/test/agama/storage/dasd/manager_test.rb @@ -101,33 +101,6 @@ def all expect(dasd2).to receive(:diag_wanted=).with(false) subject.probe end - - it "locks devices that are not offline" do - subject.probe - expect(subject.send(:device_locked?, dasd1)).to be(true) - expect(subject.send(:device_locked?, dasd2)).to be(false) - end - - context "when a configuration is already present" do - let(:config_json) { { devices: [{ channel: "0.0.0100" }] } } - - before do - allow(subject).to receive(:config_json).and_return(config_json) - end - - context "if a device is part of the configuration" do - before do - allow(dasd1).to receive(:offline?).and_return(false) - allow(dasd2).to receive(:offline?).and_return(false) - end - - it "does not lock active devices that are part of the configuration" do - subject.probe - expect(subject.send(:device_locked?, dasd1)).to be(false) - expect(subject.send(:device_locked?, dasd2)).to be(true) - end - end - end end describe "#configured?" do @@ -207,7 +180,6 @@ def all before do devices.each { |d| allow(d).to receive(:diag_wanted=) } allow(reader).to receive(:update_info) - allow(subject).to receive(:device_locked?).and_return(false) # Mock all operations allow(Agama::Storage::DASD::EnableOperation).to receive(:new).and_return(enable_operation) @@ -338,27 +310,10 @@ def all allow(dasd4).to receive(:active?).and_return(false) end - it "deactivates the unlisted device if active" do - expect(Agama::Storage::DASD::DisableOperation).to receive(:new) do |devices, _| - expect(devices).to contain_exactly(dasd1, dasd3) - disable_operation - end + it "does not deactivate the unlisted devices" do + expect(Agama::Storage::DASD::DisableOperation).to_not receive(:new) subject.configure(config_json) end - - context "and some unlisted device is locked" do - before do - allow(subject).to receive(:device_locked?).with(dasd1).and_return(true) - end - - it "does not deactivate the locked devices" do - expect(Agama::Storage::DASD::DisableOperation).to receive(:new) do |devices, _| - expect(devices).to contain_exactly(dasd3) - disable_operation - end - subject.configure(config_json) - end - end end context "if the config formats a device" do @@ -590,42 +545,6 @@ def all subject.configure(config_json) end end - - context "if a device is configured" do - let(:config_json) do - { - devices: [ - { - channel: "0.0.0002", - state: "active", - format: false - }, - { - channel: "0.0.0003", - state: "active", - format: false - } - ] - } - end - - before do - allow(dasd1).to receive(:offline?).and_return(true) - allow(dasd2).to receive(:offline?).and_return(false) - allow(dasd2).to receive(:active?).and_return(true) - allow(dasd3).to receive(:offline?).and_return(false) - allow(dasd4).to receive(:offline?).and_return(false) - allow(subject).to receive(:device_locked?).and_call_original - end - - it "removes configured devices from locked devices" do - subject.configure(config_json) - expect(subject.send(:device_locked?, dasd1)).to eq(false) - expect(subject.send(:device_locked?, dasd2)).to eq(false) - expect(subject.send(:device_locked?, dasd3)).to eq(false) - expect(subject.send(:device_locked?, dasd4)).to eq(true) - end - end end describe "#device_type" do From e3d7e67bd99e1acaec7b1d8be55f43f30fcd0722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Iv=C3=A1n=20L=C3=B3pez=20Gonz=C3=A1lez?= Date: Mon, 16 Feb 2026 16:33:08 +0000 Subject: [PATCH 2/2] Changelog --- 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 dc35b3e97d..df734fb856 100644 --- a/service/package/rubygem-agama-yast.changes +++ b/service/package/rubygem-agama-yast.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Mon Feb 16 16:31:50 UTC 2026 - José Iván López González + +- Avoid automatic deactivation of unlisted DASD devices + (gh#agama-project/agama#3181). + ------------------------------------------------------------------- Fri Feb 13 09:22:48 UTC 2026 - José Iván López González