]> git.proxmox.com Git - pve-manager.git/commit
api: ceph osd: factor out getting PSS stat & improve error handling
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 4 Sep 2023 12:24:17 +0000 (14:24 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 4 Sep 2023 12:44:33 +0000 (14:44 +0200)
commitb4b39b55f856d2a4384e587af421f8fd9bbf0fed
tree2bebb4ae62548f29e2766ac8a8628a521dcbb18b
parentf7b7e942a7d03202e00d4171071f93efc046710b
api: ceph osd: factor out getting PSS stat & improve error handling

Do not crowd the higher level API endpoint handler code directly with
some rather low level procfs parsing code, rather factor that out in a
helper. Make said helper private for now so that anybody wanting to
use cannot do so, and thus increase the chance that said dev will
actually think about if this makes sense as is as a general interface.

Avoid fatal die's for the odd case that the smaps_rollup file cannot
be opened, or the even less likely case where PSS stats cannot be
found in the content.

The former could happen due to the general TOCTOU race here, i.e., the
PID we get from systemctl service status parsing isn't guaranteed to
exist anymore when we read from procfs, and if, it's actually not
guaranteed to still be the OSD - but we cannot easily use pidfd's
here and OSD stops are not something that happens frequently, but in
anyway avoid that such a thing fails the whole API call only because a
single metric is affected.

In the long rung it might be better to add a "errors" array to the
response, so that the user can be informed about such an (odd) thing
happening.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/API2/Ceph/OSD.pm