check_vault_health fails to fetch snap version

Bug #2071612 reported by Giuseppe Petralia
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
vault-charm
New
Undecided
Unassigned

Bug Description

This is happening on a jammy yoga cloud running:

charm-vault 1.8/stable

root@vault-1:~# snap info snapd | grep installed:
installed: 2.63 (21759) 40MB snapd

when run check_vault_health.py it returns critical

root@vault-1:~# /usr/lib/nagios/plugins/check_vault_health.py
CRITICAL: failed to fetch version of installed vault snap: Expecting value: line 1 column 1 (char 0)

This is because it fails to load the result when querying snapd socket [0]

snapd.recv returrns

['HTTP/1.1 200 OK\r',
 'Content-Type: application/json\r',
 'Date: Mon, 01 Jul 2024 11:29:26 GMT\r',
 'Transfer-Encoding: chunked\r',
 '\r',
 '8f4\r',
 '{"type":"sync","status-code":200,"status":"OK","result":{"id":"*********","title":"vault","summary":"...","icon":"https://dashboard.snapcraft.io/site_media/appmedia/2017/09/android-chrome-512x512.png","installed-size":290283520,"install-date":"2024-06-10T12:23:58.413633312Z","name":"vault","publisher":{"id":"canonical","username":"canonical","display-name":"Canonical","validation":"verified"},"developer":"canonical","status":"active","type":"app","base":"core18","version":"1.8.8","channel":"1.8/stable","tracking-channel":"1.8/stable","ignore-validation":false,"revision":"2066","confinement":"strict","private":false,"devmode":false,"jailmode":false,"apps":[{"snap":"vault","name":"vault"}],"mounted-from":"/var/lib/snapd/snaps/vault_2066.snap","contact":"","website":"https://github.com/canonical/snap-vault",}}\r',
 '0\r',
 '\r',
 '']

and the check takes [-1] which is ''

0. https://github.com/openstack/charm-vault/blob/stable/1.8/src/files/nagios/check_vault_health.py#L40

Revision history for this message
Giuseppe Petralia (peppepetra) wrote :

I can workaround changing

`snapd.recv(1024 * 1024).decode('utf-8').split('\n')[-1])`

with

`snapd.recv(1024 * 1024).decode('utf-8').split('\n')[-4])`

Revision history for this message
Alex Kavanagh (ajkavanagh) wrote :

The fix is on master at https://review.opendev.org/c/openstack/charm-vault/+/917766 - it just needs backporting to 1.8 ... 1.5.

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.