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; 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/package/rubygem-agama.changes b/service/package/rubygem-agama.changes index 5fded27b4d..89f861fbf7 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 + (bsc#1213194). + ------------------------------------------------------------------- Fri Aug 18 14:17:13 UTC 2023 - Knut Anderssen 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