Skip to content

Commit

Permalink
[maas] Support MAAS 3.5
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
brigaccess committed Aug 23, 2023
1 parent e11a594 commit 728a4b9
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion sos/report/plugins/maas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -62,13 +68,25 @@ 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:
self.add_cmd_output([
'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([
Expand Down

0 comments on commit 728a4b9

Please sign in to comment.