NRPE check return error after snap upgrade
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
vault-charm |
Triaged
|
High
|
Jadon Naas |
Bug Description
We have hit the issue where snap socket return more information in the result, causing vault version check break.
The function only get information from the last element in the returned information.
```
info = json.loads(
snapd.recv(1024 * 1024).decode(
```
However I have hit some different response on the following version:
```
snap 2.61.2
snapd 2.61.2
```
Where the response become
```
['HTTP/1.1 200 OK\r', 'Content-Type: application/
```
Noticed there is 3 more elements in the end of the array, resulting the check failed.
A better approach is to check if the element has `vault` in it and parse accordingly.
```
original_response = snapd.recv(1024 * 1024).decode(
result = [ele for ele in original_response if "vault" in ele]
info = json.loads(
```
description: | updated |
Changed in vault-charm: | |
importance: | Critical → High |
I confirmed the version check failing is happening for the Vault snap on version 1.15.6 on 1.15/stable right now. I got this error when I worked through the commands in the get_vault_ snap_version( ) function:
Traceback (most recent call last): python3. 8/json/ __init_ _.py", line 357, in loads decoder. decode( s) python3. 8/json/ decoder. py", line 337, in decode python3. 8/json/ decoder. py", line 355, in raw_decode ("Expecting value", s, err.value) from None JSONDecodeError : Expecting value: line 1 column 1 (char 0)
File "<stdin>", line 5, in <module>
File "/usr/lib/
return _default_
File "/usr/lib/
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/
raise JSONDecodeError
json.decoder.
Is this the kind of error you were seeing?
Also, what version of the Vault snap are you using? I did not get this error on version 1.5.9 of the Vault snap, for example.
Thank you for the fix suggestion! I did confirm that the fix you suggested would work. Here is output from working through that fix you provided:
>>> snapd = socket. socket( socket. AF_UNIX, socket.SOCK_STREAM) SNAPD_SOCKET) SNAPD_INFO_ REQUEST. format( snap='vault' ).encode( 'utf-8' )) 'utf-8' ).split( '\n') result[ 0]) 2EU64whkZhw9QYY sMH', 'title': 'vault', 'summary': 'Vault is a tool for securely accessing secrets.', 'description': 'A modern system requires access to a multitude of secrets: database\ ncredentials, API keys for external services, credentials for service- oriented\ narchitecture communication, etc. Understanding who is accessing what secrets\nis already very difficult and platform-specific. Adding on key rolling,\nsecure storage, and detailed audit logs is almost impossible without a custom\nsolution. This is where Vault steps in.\n\nThis snap is maintained by Canonical. \n\n**Usage* *\n \n* To start the Vault service, edit the configuration file at `/var/snap/ vault/common/ vault.hcl` and start the service with `sudo snap start vault.vaultd`.\n\n* To use the Vault Client, run `vault` commands. For example: `vault status`.', 'icon': 'https:/ /dashboard. snapcraft. io/site_ media/appmedia/ 2017/09/ android- chrome- 512x512. png', 'installed-size': 191340544, 'install-date': '2024-04- 09T19:44: 21.65660055Z' , 'name': 'vault', 'publisher': {'id': 'canonical', 'username': 'canonical', 'display-name': 'Canonical', 'validation': 'verified'}, 'developer': 'canonical', 'status': 'active', 'type': 'app', 'base': 'core22', 'version': '1.15.6', 'channel': '1.15/stable', 'tracking-channel': '1.15/stable', 'ignore- validation' : False, 'revision': '2213', 'confinement': 'strict', 'private': False, 'devmode': False, 'jailmode': False, 'apps': [{'snap': 'vault', 'name': 'vault'}, {'snap': 'vault', 'name': 'vaultd', 'daemon': 'simple', 'daemon-scope': 'system'}], 'mounted-from': '/var/lib/ snapd/snaps/ vault_2213. snap', 'links': {'issues': ['https:/ /github. com/canonical/ snap-vault/ issues'], 'source': ['https:/ /github. com/hashicor...
>>> snapd.connect(
>>> snapd.sendall(
>>> original_response = snapd.recv(1024 * 1024).decode(
>>> result = [ele for ele in original_response if "vault" in ele]
>>> info = json.loads(
>>> print(info)
{'type': 'sync', 'status-code': 200, 'status': 'OK', 'result': {'id': 'bIb4p4yWWjyZdo