all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: Lukas Wagner <l.wagner@proxmox.com>
Cc: Proxmox Datacenter Manager development discussion
	<pdm-devel@lists.proxmox.com>
Subject: Re: [pdm-devel] [PATCH datacenter-manager 1/7] server: generic multi-client wrapper
Date: Wed, 12 Feb 2025 10:07:26 +0100	[thread overview]
Message-ID: <5imy6uncalrjvwrcxwzdzp3o6tkemdtiflehbtgeduckvgpyrq@mvzx2puh54ny> (raw)
In-Reply-To: <04e144d9-5e77-418d-8067-5c49298d815b@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


  reply	other threads:[~2025-02-12  9:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-04  9:55 [pdm-devel] [PATCH pdm 0/7] multi-remote client and node reachability cache Wolfgang Bumiller
2025-02-04  9:55 ` [pdm-devel] [PATCH datacenter-manager 1/7] server: generic multi-client wrapper Wolfgang Bumiller
2025-02-11 14:50   ` Lukas Wagner
2025-02-12  9:07     ` Wolfgang Bumiller [this message]
2025-02-04  9:55 ` [pdm-devel] [PATCH datacenter-manager 2/7] server: store pve MultiClient for re-use Wolfgang Bumiller
2025-02-04  9:55 ` [pdm-devel] [PATCH datacenter-manager 3/7] server: separate ConnectInfo from client creation Wolfgang Bumiller
2025-02-04  9:55 ` [pdm-devel] [PATCH datacenter-manager 4/7] server: cache pve node reachability and names Wolfgang Bumiller
2025-02-04  9:55 ` [pdm-devel] [PATCH datacenter-manager 5/7] server: don't try to connect to known-unreachable servers Wolfgang Bumiller
2025-02-04  9:55 ` [pdm-devel] [PATCH datacenter-manager 6/7] server: try previously unreachable clients as last resort Wolfgang Bumiller
2025-02-04  9:55 ` [pdm-devel] [PATCH datacenter-manager 7/7] server: add some tracing instrumentation Wolfgang Bumiller
2025-02-11 14:50 ` [pdm-devel] [PATCH pdm 0/7] multi-remote client and node reachability cache Lukas Wagner

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=5imy6uncalrjvwrcxwzdzp3o6tkemdtiflehbtgeduckvgpyrq@mvzx2puh54ny \
    --to=w.bumiller@proxmox.com \
    --cc=l.wagner@proxmox.com \
    --cc=pdm-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