* [pve-devel] [PATCH proxmox-rrd-migration-tool] fix failure during migration when there are no guest metrics yet
@ 2025-07-31 8:28 Lukas Wagner
2025-08-04 9:30 ` [pve-devel] applied: " Fiona Ebner
0 siblings, 1 reply; 2+ messages in thread
From: Lukas Wagner @ 2025-07-31 8:28 UTC (permalink / raw)
To: pve-devel
If a node never has had any guests on it, the pve2-vm directory does not
exist yet, which led to a failure when attempting to read the contents
of this directory. This is fixed by explicitly checking for a 'not
found' error (we still want to fail for other kinds of errors).
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
src/main.rs | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/main.rs b/src/main.rs
index 6fcdc10..fb58d3a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -2,6 +2,7 @@ use anyhow::{bail, Error, Result};
use std::{
ffi::{CStr, CString, OsString},
fs,
+ io::ErrorKind,
os::unix::{ffi::OsStrExt, fs::PermissionsExt},
path::{Path, PathBuf},
sync::Arc,
@@ -319,7 +320,15 @@ fn mv_old(file: &str) -> Result<()> {
fn collect_rrd_files(location: &PathBuf) -> Result<Vec<(CString, OsString)>> {
let mut files: Vec<(CString, OsString)> = Vec::new();
- fs::read_dir(location)?
+ let contents = match fs::read_dir(location) {
+ Ok(contents) => contents,
+ Err(e) if e.kind() == ErrorKind::NotFound => {
+ return Ok(files);
+ }
+ Err(e) => return Err(e.into()),
+ };
+
+ contents
.filter(|f| f.is_ok())
.map(|f| f.unwrap().path())
.filter(|f| f.is_file() && f.extension().is_none())
@@ -409,6 +418,11 @@ fn migrate_guests(
let guest_source_files = collect_rrd_files(&source_dir_guests)?;
+ if guest_source_files.is_empty() {
+ println!("No guest metrics to migrate");
+ return Ok(());
+ }
+
if !target_dir_guests.exists() && migrate {
println!("Creating new directory: '{}'", target_dir_guests.display());
std::fs::create_dir(&target_dir_guests)?;
--
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 proxmox-rrd-migration-tool] fix failure during migration when there are no guest metrics yet
2025-07-31 8:28 [pve-devel] [PATCH proxmox-rrd-migration-tool] fix failure during migration when there are no guest metrics yet Lukas Wagner
@ 2025-08-04 9:30 ` Fiona Ebner
0 siblings, 0 replies; 2+ messages in thread
From: Fiona Ebner @ 2025-08-04 9:30 UTC (permalink / raw)
To: Proxmox VE development discussion, Lukas Wagner
Am 31.07.25 um 10:29 AM schrieb Lukas Wagner:
> If a node never has had any guests on it, the pve2-vm directory does not
> exist yet, which led to a failure when attempting to read the contents
> of this directory. This is fixed by explicitly checking for a 'not
> found' error (we still want to fail for other kinds of errors).
>
> Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
For the record, this was already applied:
https://git.proxmox.com/?p=proxmox-rrd-migration-tool.git;a=commit;h=b22111ef44df241b12c0d893bb4f0ee3a2bb04c1
_______________________________________________
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-04 9:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-31 8:28 [pve-devel] [PATCH proxmox-rrd-migration-tool] fix failure during migration when there are no guest metrics yet Lukas Wagner
2025-08-04 9:30 ` [pve-devel] applied: " Fiona Ebner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox