From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: Filip Schauer <f.schauer@proxmox.com>
Cc: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] applied: [PATCH vma-to-pbs] fix #5994: wait for decompression processes to exit
Date: Thu, 6 Feb 2025 15:20:25 +0100 [thread overview]
Message-ID: <7s66qv4gugem6jmaevpfreers4y53oqtus6w6cg2rfhw2rgwiu@upubw7upowdb> (raw)
In-Reply-To: <20241217151255.155032-1-f.schauer@proxmox.com>
applied, thanks
On Tue, Dec 17, 2024 at 04:12:55PM +0100, Filip Schauer wrote:
> Wait for zstd, lzop or zcat processes to exit when uploading a
> compressed VMA file. This prevents these processes from lingering as
> zombies. Also check the exit code of the processes, to detect potential
> failures during decompression.
>
> Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
> ---
> src/vma2pbs.rs | 22 +++++++++++++++-------
> 1 file changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/src/vma2pbs.rs b/src/vma2pbs.rs
> index 7457b9a..1be52b9 100644
> --- a/src/vma2pbs.rs
> +++ b/src/vma2pbs.rs
> @@ -4,7 +4,7 @@ use std::collections::HashMap;
> use std::ffi::{c_char, CStr, CString, OsString};
> use std::fs::File;
> use std::io::{stdin, BufRead, BufReader, Read};
> -use std::process::{Command, Stdio};
> +use std::process::{Child, Command, Stdio};
> use std::ptr;
> use std::sync::atomic::{AtomicU64, Ordering};
> use std::sync::Arc;
> @@ -515,7 +515,7 @@ fn upload_vma_file(pbs_args: &PbsArgs, backup_args: &VmaBackupArgs) -> Result<()
> None => log::info!("Uploading VMA backup from (stdin)"),
> };
>
> - let vma_file: Box<dyn BufRead> = match &backup_args.compression {
> + let (vma_file, decompproc): (Box<dyn BufRead>, Option<Child>) = match &backup_args.compression {
> Some(compression) => {
> let vma_file_path = backup_args
> .vma_file_path
> @@ -534,16 +534,16 @@ fn upload_vma_file(pbs_args: &PbsArgs, backup_args: &VmaBackupArgs) -> Result<()
> }
> Compression::GZip => Command::new("zcat"),
> };
> - let process = cmd.arg(vma_file_path).stdout(Stdio::piped()).spawn()?;
> - let stdout = process.stdout.expect("Failed to capture stdout");
> - Box::new(BufReader::new(stdout))
> + let mut process = cmd.arg(vma_file_path).stdout(Stdio::piped()).spawn()?;
> + let stdout = process.stdout.take().expect("Failed to capture stdout");
> + (Box::new(BufReader::new(stdout)), Some(process))
> }
> None => match &backup_args.vma_file_path {
> Some(vma_file_path) => match File::open(vma_file_path) {
> Err(why) => return Err(anyhow!("Couldn't open file: {why}")),
> - Ok(file) => Box::new(BufReader::new(file)),
> + Ok(file) => (Box::new(BufReader::new(file)), None),
> },
> - None => Box::new(BufReader::new(stdin())),
> + None => (Box::new(BufReader::new(stdin())), None),
> },
> };
>
> @@ -565,6 +565,14 @@ fn upload_vma_file(pbs_args: &PbsArgs, backup_args: &VmaBackupArgs) -> Result<()
> upload_configs(&vma_reader, pbs)?;
> upload_block_devices(vma_reader, pbs)?;
>
> + if let Some(mut decompproc) = decompproc {
> + let status = decompproc.wait()?;
> +
> + if !status.success() {
> + bail!("Failed to decompress file with exit code: {status}");
> + }
> + }
> +
> if proxmox_backup_finish(pbs, &mut pbs_err) < 0 {
> handle_pbs_error(pbs_err, "proxmox_backup_finish")?;
> }
> --
> 2.39.5
>
>
>
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
>
>
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
prev parent reply other threads:[~2025-02-06 14:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-17 15:12 [pbs-devel] " Filip Schauer
2025-02-06 14:20 ` Wolfgang Bumiller [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7s66qv4gugem6jmaevpfreers4y53oqtus6w6cg2rfhw2rgwiu@upubw7upowdb \
--to=w.bumiller@proxmox.com \
--cc=f.schauer@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.