From b554b9f41829f5cb8fa1befb55f2fce1cdd4b51f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Fri, 18 Aug 2023 10:21:08 +0100 Subject: [PATCH 1/4] Properly report the status on single-product scenarios --- service/lib/agama/dbus/manager.rb | 7 +++++++ service/lib/agama/manager.rb | 15 +++++++++++++++ service/test/agama/dbus/manager_test.rb | 16 +++++++++------- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/service/lib/agama/dbus/manager.rb b/service/lib/agama/dbus/manager.rb index c12d82ca64..a8cb2b5ff0 100644 --- a/service/lib/agama/dbus/manager.rb +++ b/service/lib/agama/dbus/manager.rb @@ -133,6 +133,13 @@ def busy_services backend.busy_services end + # Redefines #service_status to use the one from the backend + # + # @return [DBus::ServiceStatus] + def service_status + backend.service_status + end + private # @return [Agama::Manager] diff --git a/service/lib/agama/manager.rb b/service/lib/agama/manager.rb index 2b214fabaa..6eea3dba66 100644 --- a/service/lib/agama/manager.rb +++ b/service/lib/agama/manager.rb @@ -25,6 +25,7 @@ require "agama/with_progress" require "agama/installation_phase" require "agama/service_status_recorder" +require "agama/dbus/service_status" require "agama/dbus/clients/locale" require "agama/dbus/clients/software" require "agama/dbus/clients/storage" @@ -50,6 +51,9 @@ class Manager # @return [InstallationPhase] attr_reader :installation_phase + # @return [DBus::ServiceStatus] + attr_reader :service_status + # Constructor # # @param logger [Logger] @@ -58,18 +62,22 @@ def initialize(config, logger) @logger = logger @installation_phase = InstallationPhase.new @service_status_recorder = ServiceStatusRecorder.new + @service_status = DBus::ServiceStatus.new.busy end # Runs the startup phase def startup_phase + service_status.busy installation_phase.startup config_phase if software.selected_product logger.info("Startup phase done") + service_status.idle end # Runs the config phase def config_phase + service_status.busy installation_phase.config start_progress(2) @@ -80,11 +88,14 @@ def config_phase rescue StandardError => e logger.error "Startup error: #{e.inspect}. Backtrace: #{e.backtrace}" # TODO: report errors + ensure + service_status.idle end # Runs the install phase # rubocop:disable Metrics/AbcSize def install_phase + service_status.busy installation_phase.install start_progress(7) @@ -108,6 +119,10 @@ def install_phase end logger.info("Install phase done") + rescue StandardError => e + logger.error "Installation error: #{e.inspect}. Backtrace: #{e.backtrace}" + ensure + service_status.idle end # rubocop:enable Metrics/AbcSize diff --git a/service/test/agama/dbus/manager_test.rb b/service/test/agama/dbus/manager_test.rb index 6299fcfdd3..31e58494e4 100644 --- a/service/test/agama/dbus/manager_test.rb +++ b/service/test/agama/dbus/manager_test.rb @@ -29,13 +29,15 @@ subject { described_class.new(backend, logger) } let(:logger) { Logger.new($stdout, level: :warn) } + let(:service_status) { Agama::DBus::ServiceStatus.new.idle } let(:backend) do instance_double(Agama::Manager, installation_phase: installation_phase, software: software_client, on_services_status_change: nil, - valid?: true) + valid?: true, + service_status: service_status) end let(:installation_phase) { Agama::InstallationPhase.new } @@ -98,7 +100,7 @@ describe "#config_phase" do context "when the service is idle" do before do - subject.service_status.idle + service_status.idle end it "runs the config phase, setting the service as busy meanwhile" do @@ -112,11 +114,11 @@ context "when the service is busy" do before do - subject.service_status.busy + service_status.busy end it "raises a D-Bus error" do - expect { subject.config_phase }.to raise_error(::DBus::Error) + expect { subject.config_phase }.to raise_error(DBus::Error) end end end @@ -124,7 +126,7 @@ describe "#install_phase" do context "when the service is idle" do before do - subject.service_status.idle + service_status.idle end it "runs the install phase, setting the service as busy meanwhile" do @@ -148,11 +150,11 @@ context "when the service is busy" do before do - subject.service_status.busy + service_status.busy end it "raises a D-Bus error" do - expect { subject.install_phase }.to raise_error(::DBus::Error) + expect { subject.install_phase }.to raise_error(DBus::Error) end end end From 634c6bca4a65cb200834327dc7c261b60ea3971a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Fri, 18 Aug 2023 13:27:12 +0100 Subject: [PATCH 2/4] Wait until the manager is ready to call the D-Bus CanInstall method --- rust/agama-cli/src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/agama-cli/src/main.rs b/rust/agama-cli/src/main.rs index 5baabc713c..1c895b5ee3 100644 --- a/rust/agama-cli/src/main.rs +++ b/rust/agama-cli/src/main.rs @@ -54,13 +54,13 @@ async fn install(manager: &ManagerClient<'_>, max_attempts: u8) -> anyhow::Resul println!("Agama's manager is busy. Waiting until it is ready..."); } + // Make sure that the manager is ready + manager.wait().await?; + if !manager.can_install().await? { return Err(CliError::ValidationError)?; } - // Display the progress (if needed) and makes sure that the manager is ready - manager.wait().await?; - let progress = task::spawn(async { show_progress().await }); // Try to start the installation up to max_attempts times. let mut attempts = 1; From d5726c4e880ed396debab0c8414f8317c044611c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Fri, 18 Aug 2023 13:31:02 +0100 Subject: [PATCH 3/4] Update the changes file --- service/package/rubygem-agama.changes | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/service/package/rubygem-agama.changes b/service/package/rubygem-agama.changes index 5fded27b4d..8d3d62f48e 100644 --- a/service/package/rubygem-agama.changes +++ b/service/package/rubygem-agama.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Mon Aug 21 11:15:50 UTC 2023 - Imobach Gonzalez Sosa + +- Set the manager service as busy during the startup phase when + a single product is available (bsc#1213194). + ------------------------------------------------------------------- Fri Aug 18 14:17:13 UTC 2023 - Knut Anderssen From 8828b211fbb49d2ceeb6a0921b639b5aa04818cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Mon, 21 Aug 2023 13:40:17 +0100 Subject: [PATCH 4/4] Fix the description of the latest change --- service/package/rubygem-agama.changes | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/service/package/rubygem-agama.changes b/service/package/rubygem-agama.changes index 8d3d62f48e..89f861fbf7 100644 --- a/service/package/rubygem-agama.changes +++ b/service/package/rubygem-agama.changes @@ -1,8 +1,8 @@ ------------------------------------------------------------------- Mon Aug 21 11:15:50 UTC 2023 - Imobach Gonzalez Sosa -- Set the manager service as busy during the startup phase when - a single product is available (bsc#1213194). +- Set the manager service as busy during the startup phase + (bsc#1213194). ------------------------------------------------------------------- Fri Aug 18 14:17:13 UTC 2023 - Knut Anderssen