From 728a4b94c7312c43b4f17deeb5ae93e91eb820d8 Mon Sep 17 00:00:00 2001 From: Igor Brovtsin Date: Mon, 14 Aug 2023 15:31:51 +0400 Subject: [PATCH] [maas] Support MAAS 3.5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In MAAS 3.5, system journal is used by all the services, therefore the log size is significantly increased compared to the previous MAAS versions. For snap this means that `journalctl` might need a long time to collect and filter the log files before outputting them. This sometimes leads to `maas` plugin timeouts with 3.5 snap, as `sos` performs automatic log collection for services listed in `services` tuple without any filters other thanĀ unit name, unless explicitly specified by user. We want the plugin to work without additional params, so we service declaration for 3.5 snap is ommitted. Instead, `check_enabled` is used to activate the plugin. Logs are then collected via `add_journal` call with a sane default limit to avoid timeouts. Signed-off-by: Igor Brovtsin --- sos/report/plugins/maas.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/sos/report/plugins/maas.py b/sos/report/plugins/maas.py index d79201121f..b89f2f8355 100644 --- a/sos/report/plugins/maas.py +++ b/sos/report/plugins/maas.py @@ -28,8 +28,14 @@ class Maas(Plugin, UbuntuPlugin): 'maas-rackd', 'maas-regiond', 'maas-syslog', - # For the snap: + # MAAS 3.5 deb: + 'maas-temporal', + 'maas-apiserver', + 'maas-agent', + # For the pre-3.5 snap: 'snap.maas.supervisor', + # MAAS 3.5 snap uses `snap.maas.pebble` service, but it's not + # included here to prevent automatic journald log collection. ) option_list = [ @@ -62,6 +68,9 @@ def _is_snap_installed(self): return maas_pkg['pkg_manager'] == 'snap' return False + def check_enabled(self): + return super().check_enabled() or self.is_service("snap.maas.pebble") + def setup(self): self._is_snap = self._is_snap_installed() if self._is_snap: @@ -69,6 +78,15 @@ def setup(self): 'snap info maas', 'maas status' ]) + + if self.is_service("snap.maas.pebble"): + # Because `snap.maas.pebble` is not in the services + # tuple to prevent timeouts caused by log collection, + # service status and logs are collected here. + self.add_service_status("snap.maas.pebble") + since = self.get_option("since") or "-1days" + self.add_journal(units="snap.maas.pebble", since=since) + # Don't send secrets self.add_forbidden_path("/var/snap/maas/current/bind/session.key") self.add_copy_spec([