From eba57027e22915462f26e5514c4b49fc01635499 Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Thu, 23 Nov 2023 08:38:05 +0100 Subject: [PATCH 01/17] Even less verbose agama logs store --- rust/agama-cli/src/logs.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rust/agama-cli/src/logs.rs b/rust/agama-cli/src/logs.rs index 027da2c9a2..d69dadc99a 100644 --- a/rust/agama-cli/src/logs.rs +++ b/rust/agama-cli/src/logs.rs @@ -398,7 +398,11 @@ fn store(options: LogOptions) -> Result<(), io::Error> { showln(verbose, "\t- proceeding output of commands"); // store it - showln(true, format!("Storing result in: \"{}\"", result).as_str()); + if verbose { + showln(true, format!("Storing result in: \"{}\"", result).as_str()); + } else { + showln(true, result.as_str()); + } for log in log_sources.iter() { show( From a8ad314ad6947d167d064821f8ebc883664967a3 Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Thu, 23 Nov 2023 10:05:04 +0100 Subject: [PATCH 02/17] Make collect_logs use new agama logs store command --- service/lib/agama/manager.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/service/lib/agama/manager.rb b/service/lib/agama/manager.rb index ae9f0d4401..fa2286395e 100644 --- a/service/lib/agama/manager.rb +++ b/service/lib/agama/manager.rb @@ -207,12 +207,8 @@ def valid? # # @param user [String] local username who will own archive # @return [String] path to created archive - def collect_logs(user) - output = Yast::Execute.locally!("save_y2logs", stderr: :capture) - path = output[/^.* (\/tmp\/y2log-\S*)/, 1] - Yast::Execute.locally!("chown", "#{user}:", path) - - path + def collect_logs(_user) + %x(agama logs store).strip end # Whatever has to be done at the end of installation From 69ef2a0cda5fcfaa995bb37ff7f1fc22f6e17d20 Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Thu, 23 Nov 2023 10:13:08 +0100 Subject: [PATCH 03/17] Removed user parameter from collect_logs It was always used with root anyway -> so simplify it a bit. --- service/lib/agama/dbus/manager.rb | 6 +++--- service/lib/agama/manager.rb | 3 +-- web/src/client/manager.js | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/service/lib/agama/dbus/manager.rb b/service/lib/agama/dbus/manager.rb index 1a759ce672..d1f129d18e 100644 --- a/service/lib/agama/dbus/manager.rb +++ b/service/lib/agama/dbus/manager.rb @@ -60,7 +60,7 @@ def initialize(backend, logger) dbus_method(:Probe, "") { config_phase } dbus_method(:Commit, "") { install_phase } dbus_method(:CanInstall, "out result:b") { can_install? } - dbus_method(:CollectLogs, "out tarball_filesystem_path:s, in user:s") { |u| collect_logs(u) } + dbus_method(:CollectLogs, "out tarball_filesystem_path:s") { collect_logs } dbus_method(:Finish, "") { finish_phase } dbus_reader :installation_phases, "aa{sv}" dbus_reader :current_installation_phase, "u" @@ -92,8 +92,8 @@ def can_install? end # Collects the YaST logs - def collect_logs(user) - backend.collect_logs(user) + def collect_logs + backend.collect_logs end # Last action for the installer diff --git a/service/lib/agama/manager.rb b/service/lib/agama/manager.rb index fa2286395e..419cb7ce2c 100644 --- a/service/lib/agama/manager.rb +++ b/service/lib/agama/manager.rb @@ -205,9 +205,8 @@ def valid? # Collects the logs and stores them into an archive # - # @param user [String] local username who will own archive # @return [String] path to created archive - def collect_logs(_user) + def collect_logs %x(agama logs store).strip end diff --git a/web/src/client/manager.js b/web/src/client/manager.js index ee847521fc..9a722e89f3 100644 --- a/web/src/client/manager.js +++ b/web/src/client/manager.js @@ -86,7 +86,7 @@ class ManagerBaseClient { */ async fetchLogs() { const proxy = await this.client.proxy(MANAGER_IFACE); - const path = await proxy.CollectLogs("root"); + const path = await proxy.CollectLogs; const file = cockpit.file(path, { binary: true }); return file.read(); } From 6c6821e1036cbb56685b74ace1e0cb1f98dd567e Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Thu, 23 Nov 2023 10:19:06 +0100 Subject: [PATCH 04/17] Modified testsuite --- service/test/agama/manager_test.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/service/test/agama/manager_test.rb b/service/test/agama/manager_test.rb index 38a41d2ed3..ba12fe44c9 100644 --- a/service/test/agama/manager_test.rb +++ b/service/test/agama/manager_test.rb @@ -214,13 +214,12 @@ describe "#collect_logs" do it "collects the logs and returns the path to the archive" do - expect(Yast::Execute).to receive(:locally!) - .with("save_y2logs", stderr: :capture) - .and_return("Saving YaST logs to /tmp/y2log-hWBn95.tar.xz") - expect(Yast::Execute).to receive(:locally!) - .with("chown", "ytm:", /y2log-hWBn95/) + # %x returns the command output including trailing \n + expect(x).to receive(:`) + .with("agama logs store") + .and_return("/tmp/y2log-hWBn95.tar.xz\n") - path = subject.collect_logs("ytm") + path = subject.collect_logs expect(path).to eq("/tmp/y2log-hWBn95.tar.xz") end end From 4e0a8ae5182e1c4246a1b7a13b9f5da6d65d2b34 Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Thu, 23 Nov 2023 10:23:40 +0100 Subject: [PATCH 05/17] Added path param to collect_logs --- service/lib/agama/manager.rb | 8 ++++++-- service/test/agama/manager_test.rb | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/service/lib/agama/manager.rb b/service/lib/agama/manager.rb index 419cb7ce2c..f4e0f64e1d 100644 --- a/service/lib/agama/manager.rb +++ b/service/lib/agama/manager.rb @@ -205,9 +205,13 @@ def valid? # Collects the logs and stores them into an archive # + # @path [String] directory where to store logs + # # @return [String] path to created archive - def collect_logs - %x(agama logs store).strip + def collect_logs(path) + opt = "-d #{path}" if !path.nil? && !path.empty? + + %x(agama logs store #{opt}).strip end # Whatever has to be done at the end of installation diff --git a/service/test/agama/manager_test.rb b/service/test/agama/manager_test.rb index ba12fe44c9..004d061990 100644 --- a/service/test/agama/manager_test.rb +++ b/service/test/agama/manager_test.rb @@ -216,7 +216,7 @@ it "collects the logs and returns the path to the archive" do # %x returns the command output including trailing \n expect(x).to receive(:`) - .with("agama logs store") + .with("agama logs store ") .and_return("/tmp/y2log-hWBn95.tar.xz\n") path = subject.collect_logs From a3455bf53ea9a83353dabcd7f5466f33054ebf7b Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Thu, 23 Nov 2023 10:26:20 +0100 Subject: [PATCH 06/17] Automatically store agama logs at the end of installation --- service/lib/agama/manager.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/service/lib/agama/manager.rb b/service/lib/agama/manager.rb index f4e0f64e1d..6616dc7ea0 100644 --- a/service/lib/agama/manager.rb +++ b/service/lib/agama/manager.rb @@ -208,7 +208,7 @@ def valid? # @path [String] directory where to store logs # # @return [String] path to created archive - def collect_logs(path) + def collect_logs(path: nil) opt = "-d #{path}" if !path.nil? && !path.empty? %x(agama logs store #{opt}).strip @@ -216,6 +216,11 @@ def collect_logs(path) # Whatever has to be done at the end of installation def finish_installation + # TODO: make it optional + logs = collect_logs + + logger.info("Installation logs stored in #{logs}") + cmd = if iguana? "/usr/bin/agamactl -k" else From bda92538d1ed3480eddc6a357eb0ca6cdb3394b4 Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Thu, 23 Nov 2023 10:36:11 +0100 Subject: [PATCH 07/17] Fixed testsuite --- service/lib/agama/manager.rb | 2 +- service/test/agama/manager_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/service/lib/agama/manager.rb b/service/lib/agama/manager.rb index 6616dc7ea0..7ba1faa390 100644 --- a/service/lib/agama/manager.rb +++ b/service/lib/agama/manager.rb @@ -211,7 +211,7 @@ def valid? def collect_logs(path: nil) opt = "-d #{path}" if !path.nil? && !path.empty? - %x(agama logs store #{opt}).strip + `agama logs store #{opt}`.strip end # Whatever has to be done at the end of installation diff --git a/service/test/agama/manager_test.rb b/service/test/agama/manager_test.rb index 004d061990..b9e70a30fd 100644 --- a/service/test/agama/manager_test.rb +++ b/service/test/agama/manager_test.rb @@ -215,7 +215,7 @@ describe "#collect_logs" do it "collects the logs and returns the path to the archive" do # %x returns the command output including trailing \n - expect(x).to receive(:`) + expect(subject).to receive(:`) .with("agama logs store ") .and_return("/tmp/y2log-hWBn95.tar.xz\n") From b0eba84d3cec4ce97b0a6e4b433073e28c322ed9 Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Thu, 23 Nov 2023 10:39:24 +0100 Subject: [PATCH 08/17] Fixed yardoc --- service/lib/agama/manager.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/lib/agama/manager.rb b/service/lib/agama/manager.rb index 7ba1faa390..5a29693f3b 100644 --- a/service/lib/agama/manager.rb +++ b/service/lib/agama/manager.rb @@ -205,7 +205,7 @@ def valid? # Collects the logs and stores them into an archive # - # @path [String] directory where to store logs + # @param path [String] directory where to store logs # # @return [String] path to created archive def collect_logs(path: nil) From f65e6c94b9b0c5804fe6a1ce0bbb1a75d41eae70 Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Mon, 27 Nov 2023 09:39:29 +0100 Subject: [PATCH 09/17] Echo an error message when setup-service.sh fails --- setup-service.sh | 5 ++++- setup.sh | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/setup-service.sh b/setup-service.sh index 97c3dcd8af..ae2d853903 100755 --- a/setup-service.sh +++ b/setup-service.sh @@ -44,6 +44,9 @@ $SUDO zypper --non-interactive --gpg-auto-import-keys install gcc gcc-c++ make o # only install cargo if it is not available (avoid conflicts with rustup) which cargo || $SUDO zypper --non-interactive install cargo +# if agama is already running -> stop it +$SUDO systemctl stop agama.service + # - Install service rubygem dependencies ( cd $MYDIR/service @@ -70,7 +73,7 @@ $SUDO cp -v $MYDIR/service/share/dbus.conf /usr/share/dbus-1/agama.conf # cleanup previous installation [[ -d $DBUSDIR ]] && $SUDO rm -r $DBUSDIR - # create services + # create services $SUDO mkdir -p $DBUSDIR for SVC in org.opensuse.Agama*.service; do sudosed "s@\(Exec\)=/usr/bin/@\1=$MYDIR/service/bin/@" $SVC $DBUSDIR/$SVC diff --git a/setup.sh b/setup.sh index 2f4bcaeb24..c7c7c77e4b 100755 --- a/setup.sh +++ b/setup.sh @@ -23,7 +23,12 @@ fi # Backend setup -$MYDIR/setup-service.sh +if ! $MYDIR/setup-service.sh; then + echo "Backend setup failed." + echo "Agama service is NOT running." + + exit 2 +fi; # Install Frontend dependencies From 0b8ba294742f311931f679aeafd3fd21d28cca73 Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Wed, 29 Nov 2023 18:19:32 +0100 Subject: [PATCH 10/17] New TW creates new Gemfile.lock because of new bundler version --- service/Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 service/Gemfile.lock diff --git a/service/Gemfile.lock b/service/Gemfile.lock old mode 100644 new mode 100755 index 10affd1b06..9f6cb9c0d0 --- a/service/Gemfile.lock +++ b/service/Gemfile.lock @@ -73,4 +73,4 @@ DEPENDENCIES yard (~> 0.9.0) BUNDLED WITH - 2.3.26 + 2.4.22 From 1d31dcc099edb0531ee0485b07d0ebf9b3cdee3a Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Thu, 30 Nov 2023 13:37:01 +0100 Subject: [PATCH 11/17] Fixed testsuite --- web/src/client/manager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/client/manager.js b/web/src/client/manager.js index 9a722e89f3..fcd223c505 100644 --- a/web/src/client/manager.js +++ b/web/src/client/manager.js @@ -86,7 +86,7 @@ class ManagerBaseClient { */ async fetchLogs() { const proxy = await this.client.proxy(MANAGER_IFACE); - const path = await proxy.CollectLogs; + const path = await proxy.CollectLogs(); const file = cockpit.file(path, { binary: true }); return file.read(); } From b658b477474628b4f3f933c821046cd2127bf62e Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Mon, 4 Dec 2023 09:31:56 +0100 Subject: [PATCH 12/17] Define target path where to automatically store logs --- service/lib/agama/manager.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/service/lib/agama/manager.rb b/service/lib/agama/manager.rb index 5a29693f3b..7425981be1 100644 --- a/service/lib/agama/manager.rb +++ b/service/lib/agama/manager.rb @@ -216,8 +216,7 @@ def collect_logs(path: nil) # Whatever has to be done at the end of installation def finish_installation - # TODO: make it optional - logs = collect_logs + logs = collect_logs(path: "/tmp/var/logs/") logger.info("Installation logs stored in #{logs}") From 62a87bc94cbb0a9e541999f5e04fe4a0b46db9e9 Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Mon, 4 Dec 2023 10:23:26 +0100 Subject: [PATCH 13/17] Minor cleanup according to the review --- service/lib/agama/manager.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/lib/agama/manager.rb b/service/lib/agama/manager.rb index 7425981be1..48579520c6 100644 --- a/service/lib/agama/manager.rb +++ b/service/lib/agama/manager.rb @@ -209,7 +209,7 @@ def valid? # # @return [String] path to created archive def collect_logs(path: nil) - opt = "-d #{path}" if !path.nil? && !path.empty? + opt = "-d #{path}" unless path.nil? || path.empty? `agama logs store #{opt}`.strip end From 4c0fcc3cce266a236cccc556550ae607baec92af Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Mon, 4 Dec 2023 10:52:34 +0100 Subject: [PATCH 14/17] Fixed filename when manualy downloading logs --- service/Gemfile.lock | 2 +- web/src/components/core/LogsButton.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/service/Gemfile.lock b/service/Gemfile.lock index 9f6cb9c0d0..818b6affef 100755 --- a/service/Gemfile.lock +++ b/service/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - agama (6) + agama (6.devel23) cfa (~> 1.0.2) cfa_grub2 (~> 2.0.0) cheetah (~> 1.0.0) diff --git a/web/src/components/core/LogsButton.jsx b/web/src/components/core/LogsButton.jsx index 1c7987ce13..a4140931fb 100644 --- a/web/src/components/core/LogsButton.jsx +++ b/web/src/components/core/LogsButton.jsx @@ -27,7 +27,7 @@ import { Alert, Button } from "@patternfly/react-core"; import { Icon } from "~/components/layout"; import { _ } from "~/i18n"; -const FILENAME = "y2logs.tar.xz"; +const FILENAME = "agama-installation-logs.tar.bzip2"; const FILETYPE = "application/x-xz"; /** From f453560307b02a6a316b939afc0762952a1f64e1 Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Mon, 4 Dec 2023 11:03:30 +0100 Subject: [PATCH 15/17] Fixed testsuite --- web/src/components/core/LogsButton.test.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/components/core/LogsButton.test.jsx b/web/src/components/core/LogsButton.test.jsx index 0b643d3be0..cfb9c3ccb3 100644 --- a/web/src/components/core/LogsButton.test.jsx +++ b/web/src/components/core/LogsButton.test.jsx @@ -119,7 +119,7 @@ describe("LogsButton", () => { // And test what we're looking for expect(document.createElement).toHaveBeenCalledWith('a'); expect(anchorMock).toHaveAttribute("href", "fake-blob-url"); - expect(anchorMock).toHaveAttribute("download", expect.stringMatching(/y2logs/)); + expect(anchorMock).toHaveAttribute("download", expect.stringMatching(/agama-installation-logs/)); expect(anchorMock.click).toHaveBeenCalled(); // Be polite and restore document.createElement function, From b1a71736d54b82a81339ad49037be64125cc88cd Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Mon, 4 Dec 2023 11:05:47 +0100 Subject: [PATCH 16/17] Modified default logs archive name as requested in off the git review --- rust/agama-cli/src/logs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/agama-cli/src/logs.rs b/rust/agama-cli/src/logs.rs index d69dadc99a..f6b6fcf404 100644 --- a/rust/agama-cli/src/logs.rs +++ b/rust/agama-cli/src/logs.rs @@ -112,7 +112,7 @@ const DEFAULT_PATHS: [&str; 14] = [ "/linuxrc.config", ]; -const DEFAULT_RESULT: &str = "/tmp/agama_logs"; +const DEFAULT_RESULT: &str = "/tmp/agama-logs"; // what compression is used by default: // (, ) const DEFAULT_COMPRESSION: (&str, &str) = ("bzip2", "tar.bz2"); From 60739b939de0529df384a88c5471f862f0b08193 Mon Sep 17 00:00:00 2001 From: Michal Filka Date: Mon, 4 Dec 2023 11:35:55 +0100 Subject: [PATCH 17/17] Fixed Gemfile.lock --- service/Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/Gemfile.lock b/service/Gemfile.lock index 818b6affef..9f6cb9c0d0 100755 --- a/service/Gemfile.lock +++ b/service/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - agama (6.devel23) + agama (6) cfa (~> 1.0.2) cfa_grub2 (~> 2.0.0) cheetah (~> 1.0.0)