sosreport does not collect maas status when using --all-logs

Bug #2069941 reported by Arif Ali
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
sosreport
New
Unknown
sosreport (Ubuntu)
Confirmed
Medium
Unassigned

Bug Description

I am observing something strange, but maybe there is an explanation to this?

```
self.add_cmd_output([
    'snap info maas',
    'maas status'
])
```

When I run sos report -o maas then sos_commands/maas/maas_status contains expected data, however if I do sos report -o maas --all-logs then this file is empty.

(I tried changing the order and snap info maas is always there, but not maas status)

Running with -vvvv shows the following:

```
[plugin:maas] collecting output of 'maas status'
[plugin:maas] collecting 'maas status' output directly to disk
[plugin:maas] collected output of 'maas' in 1.8999457359313965 (changes=False)
[plugin:maas] collected plugin 'maas' in 2.686990976333618
```

sos.json

```
{
    "name": "maas status",
    "return_code": 0,
    "href": "../sos_commands/maas/maas_status"
}
```

sosreport: 4.5.6

``
root@maas:/tmp/sos# apt-cache policy sosreport
sosreport:
  Installed: 4.5.6-0ubuntu1~22.04.2
  Candidate: 4.5.6-0ubuntu1~22.04.2
  Version table:
 *** 4.5.6-0ubuntu1~22.04.2 500
        500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     4.3-1ubuntu2.1 500
        500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages
     4.3-1ubuntu2 500
        500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
```

Arif Ali (arif-ali)
Changed in sosreport (Ubuntu):
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Arif Ali (arif-ali) wrote :
Download full text (5.2 KiB)

From the latest/edge snap, and some initial debugging

Working with "sudo sos report -o sunbeam -a --batch --build"

ubuntu@sunbeam:~$ sudo ls -lh /var/tmp/sosreport-sunbeam-2024-06-20-vvzypam/sos_commands/sunbeam
total 120K
-rw-r--r-- 1 root root 1.2K Jun 20 08:55 juju_controller-config_-c_sunbeam-controller
-rw-r--r-- 1 root root 1006 Jun 20 08:55 juju_controller-config_-c_sunbeam-controller_--format_json
-rw-r--r-- 1 root root 285 Jun 20 08:54 juju_controllers
-rw-r--r-- 1 root root 533 Jun 20 08:55 juju_controllers_--format_json
-rw-r--r-- 1 root root 3.1K Jun 20 08:55 juju_model-config_-m_sunbeam-controller_admin.controller
-rw-r--r-- 1 root root 3.6K Jun 20 08:55 juju_model-config_-m_sunbeam-controller_admin.controller_--format_json
-rw-r--r-- 1 root root 3.5K Jun 20 08:55 juju_model-config_-m_sunbeam-controller_sunbeam.maas.openstack
-rw-r--r-- 1 root root 3.8K Jun 20 08:55 juju_model-config_-m_sunbeam-controller_sunbeam.maas.openstack_--format_json
-rw-r--r-- 1 root root 184 Jun 20 08:54 juju_model-defaults_-c_sunbeam-controller
-rw-r--r-- 1 root root 376 Jun 20 08:54 juju_models_-c_sunbeam-controller
-rw-r--r-- 1 root root 1.2K Jun 20 08:54 juju_models_-c_sunbeam-controller_--format_json
-rw-r--r-- 1 root root 1.9K Jun 20 08:55 juju_status_-m_sunbeam-controller_admin.controller
-rw-r--r-- 1 root root 6.2K Jun 20 08:55 juju_status_-m_sunbeam-controller_admin.controller_--format_json
-rw-r--r-- 1 root root 7.3K Jun 20 08:55 juju_status_-m_sunbeam-controller_sunbeam.maas.openstack
-rw-r--r-- 1 root root 42K Jun 20 08:55 juju_status_-m_sunbeam-controller_sunbeam.maas.openstack_--format_json
-rw-r--r-- 1 root root 634 Jun 20 08:54 sunbeam_cluster_list
-rw-r--r-- 1 root root 65 Jun 20 08:54 sunbeam_cluster_list_--format_yaml
-rw-r--r-- 1 root root 1.8K Jun 20 08:54 systemctl_status_snap.openstack

Non working with "sudo sos report -o sunbeam -a --batch --build --all-logs"

ubuntu@sunbeam:~$ sudo ls -lh /var/tmp/sosreport-sunbeam-2024-06-20-uygvuvy/sos_commands/sunbeam
total 12K
-rw-r--r-- 1 root root 0 Jun 20 08:56 juju_controller-config_-c_sunbeam-controller
-rw-r--r-- 1 root root 0 Jun 20 08:56 juju_controller-config_-c_sunbeam-controller_--format_json
-rw-r--r-- 1 root root 0 Jun 20 08:56 juju_controllers
-rw-r--r-- 1 root root 533 Jun 20 08:56 juju_controllers_--format_json
-rw-r--r-- 1 root root 0 Jun 20 08:56 juju_model-config_-m_sunbeam-controller_admin.controller
-rw-r--r-- 1 root root 0 Jun 20 08:56 juju_model-config_-m_sunbeam-controller_admin.controller_--format_json
-rw-r--r-- 1 root root 0 Jun 20 08:56 juju_model-config_-m_sunbeam-controller_sunbeam.maas.openstack
-rw-r--r-- 1 root root 0 Jun 20 08:56 juju_model-config_-m_sunbeam-controller_sunbeam.maas.openstack_--format_json
-rw-r--r-- 1 root root 0 Jun 20 08:56 juju_model-defaults_-c_sunbeam-controller
-rw-r--r-- 1 root root 0 Jun 20 08:56 juju_models_-c_sunbeam-controller
-rw-r--r-- 1 root root 1.2K Jun 20 08:56 juju_models_-c_sunbeam-controller_--format_json
-rw-r--r-- 1 root root 0 Jun 20 08:56 juju_status_-m_sunbeam-controller_admin.controller
-rw-r--r-- 1 root root 0 Jun 20 08:56 juju_status_-m_sunbeam-controller_admin.control...

Read more...

Revision history for this message
Arif Ali (arif-ali) wrote :

We have discovered this is due to the fact the command being run is writing to a file directly and strict confinement of snaps not able to write the file is the problem. We were able to reproduce the problem with the following python snippet

from subprocess import Popen, PIPE, STDOUT
command = ['timeout', '300s', 'maas', 'status']
file = open("my_file", mode="w+")
p = Popen(command,shell=False,stdout=file,stderr=STDOUT,bufsize=-1,close_fds=True)
p.wait(300)
print(p.returncode)
print(file.readlines())
file.close()

logs from the reporter

Jun 20 17:54:39 cyberfarm kernel: [1077437.438930] audit: type=1400 audit(1718895279.617:227878): apparmor="DENIED" operation="file_inherit" class="file" namespace="root//lxd-maas_<var-snap-lxd-common-lxd>" profile="/snap/snapd/21759/usr/lib/snapd/snap-confine" name="/tmp/sos/my_file" pid=3168174 comm="snap-confine" requested_mask="wr" denied_mask="wr" fsuid=1000000 ouid=1000000
Jun 20 17:54:39 cyberfarm kernel: [1077437.438938] audit: type=1400 audit(1718895279.617:227879): apparmor="DENIED" operation="file_inherit" class="file" namespace="root//lxd-maas_<var-snap-lxd-common-lxd>" profile="/snap/snapd/21759/usr/lib/snapd/snap-confine" name="/tmp/sos/my_file" pid=3168174 comm="snap-confine" requested_mask="wr" denied_mask="wr" fsuid=1000000 ouid=1000000

Changed in sosreport:
status: Unknown → New
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.