* [pve-devel] [PATCH cluster] pmxcfs: status: create subdirs in /var/lib/rrdcached/db when needed
@ 2025-08-01 8:34 Lukas Wagner
2025-08-01 8:50 ` [pve-devel] applied: " Thomas Lamprecht
0 siblings, 1 reply; 2+ messages in thread
From: Lukas Wagner @ 2025-08-01 8:34 UTC (permalink / raw)
To: pve-devel
Storage metrics and node metrics use a nested directory structure, e.g.:
pve-storage-9.0
somenode
local
local-lvm
The second level ('somenode') was not created correctly, leading to
errors when trying to update the RRD database.
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
src/pmxcfs/status.c | 39 +++++++++++++++++++++++++++------------
1 file changed, 27 insertions(+), 12 deletions(-)
diff --git a/src/pmxcfs/status.c b/src/pmxcfs/status.c
index b086896..a00e793 100644
--- a/src/pmxcfs/status.c
+++ b/src/pmxcfs/status.c
@@ -1301,6 +1301,12 @@ static inline const char *rrd_skip_data(const char *data, int count, char separa
return data;
}
+static inline void checked_mkdir(char* path, int mode) {
+ if (!mkdir(path, mode) && errno != EEXIST) {
+ cfs_message("could not create directory %s: %s", path, strerror(errno));
+ };
+}
+
// The key and subdirectory format used up until PVE8 is 'pve{version}-{type}/{id}' with version
// being 2 or 2.3 for VMs. Starting with PVE9 'pve-{type}-{version}/{id}'. Newer versions are only
// allowed to append new columns to the data! Otherwise this would be a breaking change.
@@ -1379,15 +1385,19 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) {
g_free(filename);
filename = g_strdup_printf("%s", filename_pve2);
+ char *dir = g_path_get_dirname(filename);
+ checked_mkdir(dir, 0755);
+ g_free(dir);
+
int argcount = sizeof(rrd_def_node) / sizeof(void *) - 1;
create_rrd_file(filename, argcount, rrd_def_node);
} else {
// no dir exists yet, use new pve-node-9.0
- const char *path = RRDDIR "/pve-node-9.0";
+ checked_mkdir(RRDDIR "/pve-node-9.0", 0755);
- if (!mkdir(path, 0755)) {
- cfs_message("could not create directory %s: %s", path, strerror(errno));
- }
+ char *dir = g_path_get_dirname(filename);
+ checked_mkdir(dir, 0755);
+ g_free(dir);
int argcount = sizeof(rrd_def_node_pve9_0) / sizeof(void *) - 1;
create_rrd_file(filename, argcount, rrd_def_node_pve9_0);
@@ -1455,10 +1465,7 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) {
create_rrd_file(filename, argcount, rrd_def_vm);
} else {
// no dir exists yet, use new pve-vm-9.0
- const char *path = RRDDIR "/pve-vm-9.0";
- if (!mkdir(path, 0755)) {
- cfs_message("could not create directory %s: %s", path, strerror(errno));
- };
+ checked_mkdir(RRDDIR "/pve-vm-9.0", 0755);
int argcount = sizeof(rrd_def_vm_pve9_0) / sizeof(void *) - 1;
create_rrd_file(filename, argcount, rrd_def_vm_pve9_0);
@@ -1515,6 +1522,9 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) {
char *dir_pve90 = g_strdup_printf(RRDDIR "/pve-storage-9.0");
if (g_file_test(dir_pve90, G_FILE_TEST_IS_DIR)) {
+ char *dir = g_path_get_dirname(filename);
+ checked_mkdir(dir, 0755);
+ g_free(dir);
int argcount = sizeof(rrd_def_storage_pve9_0) / sizeof(void *) - 1;
create_rrd_file(filename, argcount, rrd_def_storage_pve9_0);
@@ -1522,14 +1532,19 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) {
g_free(filename);
filename = g_strdup_printf("%s", filename_pve2);
+ char *dir = g_path_get_dirname(filename);
+ checked_mkdir(dir, 0755);
+ g_free(dir);
+
int argcount = sizeof(rrd_def_storage) / sizeof(void *) - 1;
create_rrd_file(filename, argcount, rrd_def_storage);
} else {
// no dir exists yet, use new pve-storage-9.0
- const char *path = RRDDIR "/pve-storage-9.0";
- if (!mkdir(path, 0755)) {
- cfs_message("could not create directory %s: %s", path, strerror(errno));
- }
+ checked_mkdir(RRDDIR "/pve-storage-9.0", 0755);
+
+ char *dir = g_path_get_dirname(filename);
+ checked_mkdir(dir, 0755);
+ g_free(dir);
int argcount = sizeof(rrd_def_storage_pve9_0) / sizeof(void *) - 1;
create_rrd_file(filename, argcount, rrd_def_storage_pve9_0);
--
2.47.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
* [pve-devel] applied: [PATCH cluster] pmxcfs: status: create subdirs in /var/lib/rrdcached/db when needed
2025-08-01 8:34 [pve-devel] [PATCH cluster] pmxcfs: status: create subdirs in /var/lib/rrdcached/db when needed Lukas Wagner
@ 2025-08-01 8:50 ` Thomas Lamprecht
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2025-08-01 8:50 UTC (permalink / raw)
To: pve-devel, Lukas Wagner
On Fri, 01 Aug 2025 10:34:15 +0200, Lukas Wagner wrote:
> Storage metrics and node metrics use a nested directory structure, e.g.:
> pve-storage-9.0
> somenode
> local
> local-lvm
>
> The second level ('somenode') was not created correctly, leading to
> errors when trying to update the RRD database.
>
> [...]
Applied, thanks!
[1/1] pmxcfs: status: create subdirs in /var/lib/rrdcached/db when needed
commit: 4544b06ec81c82c84cd724e17c803af09e27ae8c
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-01 8:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-01 8:34 [pve-devel] [PATCH cluster] pmxcfs: status: create subdirs in /var/lib/rrdcached/db when needed Lukas Wagner
2025-08-01 8:50 ` [pve-devel] applied: " Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox