From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Christian Ebner <c.ebner@proxmox.com>, pbs-devel@lists.proxmox.com
Subject: Re: [pbs-devel] [PATCH proxmox-backup 3/4] server: push: add error context to all target api calls
Date: Fri, 22 Nov 2024 10:01:28 +0100 [thread overview]
Message-ID: <173226608868.2118190.15465009393024345476@yuna.proxmox.com> (raw)
In-Reply-To: <20241121154337.471425-4-c.ebner@proxmox.com>
Quoting Christian Ebner (2024-11-21 16:43:36)
> Make it clear from the context that these error messages stem from
> the response of an api call rather than a local error.
>
> Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
> ---
> src/server/push.rs | 24 +++++++++++++++++-------
> 1 file changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/src/server/push.rs b/src/server/push.rs
> index 86cef5520..fe2e11220 100644
> --- a/src/server/push.rs
> +++ b/src/server/push.rs
> @@ -219,7 +219,9 @@ async fn remove_target_namespace(
> if params.target.supports_prune_delete_stats {
> let data = result["data"].take();
> serde_json::from_value(data).map_err(|err| {
> - format_err!("removing target namespace {target_namespace} failed - {err}")
> + format_err!(
> + "Failed to remove remote namespace {target_namespace}, remote returned: {err}"
> + )
this is attached to the wrong error - it should be attached to the client.delete call right above..
this here should instead add the context that we failed to parse the returned
value (which should never happen, that means we missed some API breakage..)
> })
> } else {
> Ok(BackupGroupDeleteStats::default())
> @@ -236,7 +238,8 @@ async fn fetch_target_groups(
> let args = Some(serde_json::json!({ "ns": target_namespace.name() }));
>
> let mut result = params.target.client.get(&api_path, args).await?;
> - let groups: Vec<GroupListItem> = serde_json::from_value(result["data"].take())?;
> + let groups: Vec<GroupListItem> = serde_json::from_value(result["data"].take())
> + .map_err(|err| format_err!("Failed to fetch remote groups, remote returned: {err}"))?;
same here, just with get instead of delete ;)
>
> let (mut owned, not_owned) = groups.into_iter().fold(
> (Vec::new(), HashSet::new()),
> @@ -277,8 +280,9 @@ async fn remove_target_group(
>
> if params.target.supports_prune_delete_stats {
> let data = result["data"].take();
> - serde_json::from_value(data)
> - .map_err(|err| format_err!("removing target group {backup_group} failed - {err}"))
> + serde_json::from_value(data).map_err(|err| {
> + format_err!("Failed to remove remote group {backup_group}, remote returned: {err}")
> + })
here as well
> } else {
> Ok(BackupGroupDeleteStats::default())
> }
> @@ -313,7 +317,7 @@ async fn check_or_create_target_namespace(
> match params.target.client.post(&api_path, Some(args)).await {
> Ok(_) => info!("Successfully created new namespace {current} on remote"),
> Err(err) => {
> - bail!("Remote creation of namespace {current} failed, remote returned: {err}")
> + bail!("Creation of remote namespace {current} failed, remote returned: {err}")
> }
> }
> existing_target_namespaces.push(current.clone());
> @@ -585,7 +589,8 @@ async fn fetch_target_snapshots(
> args["ns"] = serde_json::to_value(target_namespace)?;
> }
> let mut result = params.target.client.get(&api_path, Some(args)).await?;
> - let snapshots: Vec<SnapshotListItem> = serde_json::from_value(result["data"].take())?;
> + let snapshots: Vec<SnapshotListItem> = serde_json::from_value(result["data"].take())
> + .map_err(|err| format_err!("Failed to fetch remote snapshots, remote returned: {err}"))?;
here as well
>
> Ok(snapshots)
> }
> @@ -603,7 +608,12 @@ async fn forget_target_snapshot(
> if !target_namespace.is_root() {
> args["ns"] = serde_json::to_value(target_namespace)?;
> }
> - params.target.client.delete(&api_path, Some(args)).await?;
> + params
> + .target
> + .client
> + .delete(&api_path, Some(args))
> + .await
> + .map_err(|err| format_err!("Failed to remove remote snapshot, remote returned: {err}"))?;
this should probably be just "Request to remote returned {err}", since the call
site already logs the snapshot name and the fact that this is removal failing
;)
>
> Ok(())
> }
> --
> 2.39.5
>
>
>
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
>
>
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next prev parent reply other threads:[~2024-11-22 9:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-21 15:43 [pbs-devel] [PATCH proxmox-backup 0/4] improve push sync job log messages Christian Ebner
2024-11-21 15:43 ` [pbs-devel] [PATCH proxmox-backup 1/4] server: push: fix needless borrow clippy warning Christian Ebner
2024-11-21 15:43 ` [pbs-devel] [PATCH proxmox-backup 2/4] server: push: consistently use remote over target for error messages Christian Ebner
2024-11-21 15:43 ` [pbs-devel] [PATCH proxmox-backup 3/4] server: push: add error context to all target api calls Christian Ebner
2024-11-22 9:01 ` Fabian Grünbichler [this message]
2024-11-22 10:11 ` Christian Ebner
2024-11-21 15:43 ` [pbs-devel] [PATCH proxmox-backup 4/4] server: push: various smaller improvements to error messages Christian Ebner
2024-11-21 16:06 ` [pbs-devel] [PATCH proxmox-backup 0/4] improve push sync job log messages Gabriel Goller
2024-11-21 16:26 ` Christian Ebner
2024-11-21 17:04 ` Gabriel Goller
2024-11-21 19:32 ` Fabian Grünbichler
2024-11-22 8:41 ` Christian Ebner
2024-11-22 12:28 ` Christian Ebner
2024-11-22 9:04 ` [pbs-devel] partially-applied: " Fabian Grünbichler
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=173226608868.2118190.15465009393024345476@yuna.proxmox.com \
--to=f.gruenbichler@proxmox.com \
--cc=c.ebner@proxmox.com \
--cc=pbs-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox