etcdctl snap not able to write to /var/lib/nagios/etcd-alarm-list.txt

Bug #2021950 reported by David Negreira
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Etcd Charm
Fix Released
Medium
Unassigned

Bug Description

When we run the etcd snap in an LXD container, we see a couple of denials on the host hosting the LXD container such as:

[70955.020329] audit: type=1400 audit(1685518322.045:3895): apparmor="DENIED" operation="file_inherit" namespace="root//lxd-juju-20942a-17-lxd-0_<var-snap-lxd-common-lxd>" profile="snap.etcd.etcdctl" name="/var/lib/nagios/etcd-alarm-list.txt" pid=195823 comm="snap-exec" requested_mask="w" denied_mask="w" fsuid=1000000 ouid=1000000

In a VM for example, this works fine and I do not see the apparmor deny.

I see two ways forward to fixing the issue:

1) Add the following to the etcdctl snap apparmor profile:
/var/lib/nagios/etcd-alarm-list.txt rw,

2) Change the cron template file in order to use tee to write the file instead of directing the output at https://github.com/charmed-kubernetes/layer-etcd/blob/main/templates/check_etcd-alarms.cron
Example:

* * * * * root [ -x /snap/bin/etcdctl ] && ETCDCTL_API=3 /snap/bin/etcdctl --endpoints=127.0.0.1:4001 alarm list | tee /var/lib/nagios/etcd-alarm-list.txt > /dev/null

I am happy to send a patch, just looking to know what is your preferred way of patching before sending a PR.

Thanks.
David.

Revision history for this message
Kevin W Monroe (kwmonroe) wrote :

Hey David, thanks for the report and patch offer! My preference is option 2 (| tee) over adjusting the aa profile.

Changed in charm-etcd:
status: New → Triaged
importance: Undecided → Medium
milestone: none → 1.28
Revision history for this message
David Negreira (dnegreira) wrote :

Hi Kevin, thanks for the feedback!

I have open the PR: https://github.com/charmed-kubernetes/layer-etcd/pull/210

tags: added: needs-review
George Kraft (cynerva)
Changed in charm-etcd:
status: Triaged → Fix Committed
tags: removed: needs-review
Adam Dyess (addyess)
Changed in charm-etcd:
status: Fix Committed → Fix Released
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.