From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 8C71B70894 for ; Fri, 14 May 2021 10:42:51 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 76EC414452 for ; Fri, 14 May 2021 10:42:21 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 016CB1442B for ; Fri, 14 May 2021 10:42:21 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id C7B2742903 for ; Fri, 14 May 2021 10:42:20 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Fri, 14 May 2021 10:42:20 +0200 Message-Id: <20210514084220.10174-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.017 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [api.rs] Subject: [pbs-devel] [PATCH proxmox-backup] proxmox-restore-daemon: keep daemon active during extract api call X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 May 2021 08:42:51 -0000 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 --- 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