From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pdm-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id A85B41FF165 for <inbox@lore.proxmox.com>; Wed, 12 Feb 2025 10:08:02 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 25C8CFFF4; Wed, 12 Feb 2025 10:07:59 +0100 (CET) Date: Wed, 12 Feb 2025 10:07:26 +0100 From: Wolfgang Bumiller <w.bumiller@proxmox.com> To: Lukas Wagner <l.wagner@proxmox.com> Message-ID: <5imy6uncalrjvwrcxwzdzp3o6tkemdtiflehbtgeduckvgpyrq@mvzx2puh54ny> References: <20250204095554.39501-1-w.bumiller@proxmox.com> <20250204095554.39501-2-w.bumiller@proxmox.com> <04e144d9-5e77-418d-8067-5c49298d815b@proxmox.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <04e144d9-5e77-418d-8067-5c49298d815b@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.083 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 Subject: Re: [pdm-devel] [PATCH datacenter-manager 1/7] server: generic multi-client wrapper X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion <pdm-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pdm-devel>, <mailto:pdm-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pdm-devel/> List-Post: <mailto:pdm-devel@lists.proxmox.com> List-Help: <mailto:pdm-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel>, <mailto:pdm-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox Datacenter Manager development discussion <pdm-devel@lists.proxmox.com> Cc: Proxmox Datacenter Manager development discussion <pdm-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" <pdm-devel-bounces@lists.proxmox.com> On Tue, Feb 11, 2025 at 03:50:24PM +0100, Lukas Wagner wrote: > > > On 2025-02-04 10:55, Wolfgang Bumiller wrote: > > + > > +// doing this via a generic method is currently tedious as it requires an extra helper trait to > > +// declare the flow of the lifetime in the `self.request` vs `self.streaming_request` function from > > +// its input to its generic output future... and then you run into borrow-checker limitations... > > +macro_rules! try_request { > > + ($self:expr, $method:expr, $path_and_query:expr, $params:expr, $how:ident) => { > > + let params = $params.map(serde_json::to_value); > > + Box::pin(async move { > > + let params = params > > + .transpose() > > + .map_err(|err| proxmox_client::Error::Anyhow(err.into()))?; > > + > > + let mut last_err = None; > > + let mut timed_out = false; > > + // The iterator in use here will automatically mark a client as faulty if we move on to > > + // the `next()` one. > > + for client in $self.try_clients() { > > + if let Some(err) = last_err.take() { > > + log::error!("API client error, trying another remote - {err:?}"); > > + } > > + if timed_out { > > + timed_out = false; > > + log::error!("API client timed out, trying another remote"); > > + } > > + > > + let request = client.$how($method.clone(), $path_and_query, params.as_ref()); > > + match tokio::time::timeout($self.timeout, request).await { > > + Ok(Err(proxmox_client::Error::Client(err))) => { > > + last_err = Some(err); > > + } > > + Ok(result) => return result, > > + Err(_) => { > > + timed_out = true; > > + } > > + } > > + } > > maybe add another > > if let Some(err) = last_err { > log::error!("... {err} ..."); > } > > so that the actual `err` from the last client you tried is also logged? > Also if the *last* client to try times out I guess we would like to log that as well? Good point, will include in a v2. _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel