all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup] proxmox-restore-daemon: keep daemon active during extract api call
Date: Fri, 14 May 2021 10:42:20 +0200	[thread overview]
Message-ID: <20210514084220.10174-1-d.csapak@proxmox.com> (raw)

we only called watchdog_ping on the start of an api call, which meant
that if a single zip/pxar download took longer than 10 minutes
(which can happen on larger vms/slower connections), we shut-down
the vm and cancelled the download.

instead, spawn a second future, that polls both a sleep and the extract
handle, and ping the watchdog every 60 seconds

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/bin/proxmox_restore_daemon/api.rs | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/bin/proxmox_restore_daemon/api.rs b/src/bin/proxmox_restore_daemon/api.rs
index f1d601ce..eafff6e2 100644
--- a/src/bin/proxmox_restore_daemon/api.rs
+++ b/src/bin/proxmox_restore_daemon/api.rs
@@ -277,7 +277,7 @@ fn extract(
 
         let (mut writer, reader) = tokio::io::duplex(1024 * 64);
 
-        if pxar {
+        let handle = if pxar {
             tokio::spawn(async move {
                 let result = async move {
                     // pxar always expects a directory as it's root, so to accommodate files as
@@ -333,7 +333,7 @@ fn extract(
                 if let Err(err) = result {
                     error!("pxar streaming task failed - {}", err);
                 }
-            });
+            })
         } else {
             tokio::spawn(async move {
                 let result = async move {
@@ -355,11 +355,22 @@ fn extract(
                 if let Err(err) = result {
                     error!("file or dir streaming task failed - {}", err);
                 }
-            });
-        }
+            })
+        };
 
         let stream = tokio_util::io::ReaderStream::new(reader);
 
+        tokio::spawn(async move {
+            let mut handle = handle.fuse();
+            let interval = std::time::Duration::new(60, 0);
+            loop {
+                futures::select! {
+                    _ = handle => break,
+                    _ = tokio::time::sleep(interval).fuse() => watchdog_ping(),
+                }
+            }
+        });
+
         let body = Body::wrap_stream(stream);
         Ok(Response::builder()
             .status(StatusCode::OK)
-- 
2.20.1





             reply	other threads:[~2021-05-14  8:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-14  8:42 Dominik Csapak [this message]
2021-05-14  8:54 ` Thomas Lamprecht
2021-05-14  8:58   ` Dominik Csapak

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=20210514084220.10174-1-d.csapak@proxmox.com \
    --to=d.csapak@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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal