From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id DFD3C1FF16A for ; Fri, 30 Aug 2024 10:17:58 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 006E637063; Fri, 30 Aug 2024 10:18:28 +0200 (CEST) Date: Fri, 30 Aug 2024 10:18:22 +0200 From: Gabriel Goller To: Wolfgang Bumiller Message-ID: <20240830081822.gtk62nmcqjtw7wdg@luna.proxmox.com> References: <20240821102236.220755-1-g.goller@proxmox.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20220429 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.041 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [network.rs] Subject: Re: [pbs-devel] applied: [PATCH proxmox-backup] fix: proxmox-backup-manager network reload wait on worker 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: , Reply-To: Proxmox Backup Server development discussion Cc: pbs-devel@lists.proxmox.com Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" On 29.08.2024 14:17, Wolfgang Bumiller wrote: >applied, thanks > >On Wed, Aug 21, 2024 at 12:22:36PM GMT, Gabriel Goller wrote: >> Make the `network reload` command in proxmox-backup-manager wait on the >> api handler's workertask. Otherwise the task would be killed when the >> client exits. >> >> Signed-off-by: Gabriel Goller >> --- >> src/bin/proxmox_backup_manager/network.rs | 21 +++++++++++++++++++-- >> 1 file changed, 19 insertions(+), 2 deletions(-) >> >> diff --git a/src/bin/proxmox_backup_manager/network.rs b/src/bin/proxmox_backup_manager/network.rs >> index deac5b1b2960..0f0a50a8932a 100644 >> --- a/src/bin/proxmox_backup_manager/network.rs >> +++ b/src/bin/proxmox_backup_manager/network.rs >> @@ -129,6 +129,24 @@ fn pending_network_changes( >> Ok(Value::Null) >> } >> >> +#[api()] >> +/// Reload network changes >> +async fn reload_network_changes( >> + mut param: Value, >> + rpcenv: &mut dyn RpcEnvironment, >> +) -> Result { >> + param["node"] = "localhost".into(); >> + >> + let info = &api2::node::network::API_METHOD_RELOAD_NETWORK_CONFIG; >> + let result = match info.handler { >> + ApiHandler::Async(handler) => (handler)(param, info, rpcenv).await?, >> + _ => unreachable!(), >> + }; > >Note: we have the above pattern a lot. For `Schema` we already have a >bunch of `const fn unwrap__schema()`. >We can now also use `const {}` expressions, so maybe we should have >something like this for `ApiHandler` as well, with all these handler >functions then using something like: > > let handler = const { info.handler.unwrap_async_handler() }; > let result = (handler)(param, info, rpcenv).await? > Hmm on a second glance, I don't think we can do this currently. I tried this: pub const fn unwrap_async_handler(&self) -> &ApiAsyncHandlerFn { match self { ApiHandler::Async(a) => a, _ => panic!("unwrap_async_handler called on wrong apihandler"), } } But it doesn't compile because we have a &mut reference in `ApiAsyncHandlerFn` and mutable references in `const fn`'s currently don't work [0]. Obviously we can make everything non-const and still improve the readability. [0]: https://github.com/rust-lang/rust/issues/57349. _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel