all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup] proxmox-restore-daemon: keep daemon active during extract api call
@ 2021-05-14  8:42 Dominik Csapak
  2021-05-14  8:54 ` Thomas Lamprecht
  0 siblings, 1 reply; 3+ messages in thread
From: Dominik Csapak @ 2021-05-14  8:42 UTC (permalink / raw)
  To: pbs-devel

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





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-14  8:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-14  8:42 [pbs-devel] [PATCH proxmox-backup] proxmox-restore-daemon: keep daemon active during extract api call Dominik Csapak
2021-05-14  8:54 ` Thomas Lamprecht
2021-05-14  8:58   ` Dominik Csapak

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