From: Gabriel Goller <g.goller@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup v4] fix #4343: updated `view_task_result` to bail on task failure
Date: Wed, 27 Sep 2023 17:32:27 +0200 [thread overview]
Message-ID: <20230927153227.256298-1-g.goller@proxmox.com> (raw)
Now we make an additional request on `api2/json/.../tasks/{upid}/status` to
get the `exitstatus` of the task. This allows us to `bail` and thus
get a non-zero exit code in the cli.
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
changes v3:
- use exit code 0 (SUCCESS) on warning
changes v2:
- removed unrelated cleanup
changes v1:
- check on each iteration if the task is finished, then bubble up the
original error of the task. This was inpractical though, so we print
the error and return a generic error.
pbs-client/src/task_log.rs | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/pbs-client/src/task_log.rs b/pbs-client/src/task_log.rs
index 0bbb928d..ba8c85b8 100644
--- a/pbs-client/src/task_log.rs
+++ b/pbs-client/src/task_log.rs
@@ -96,6 +96,16 @@ pub async fn display_task_log(
}
}
+ let status_path = format!("api2/json/nodes/localhost/tasks/{upid_encoded}/status");
+ let status_result = client.get(&status_path, None).await?;
+ if status_result["data"]["status"].as_str() == Some("stopped") {
+ if let Some(status) = status_result["data"]["exitstatus"].as_str() {
+ if status != "OK" && !status.starts_with("WARNINGS") {
+ bail!("task failed");
+ }
+ }
+ }
+
Ok(())
};
--
2.39.2
next reply other threads:[~2023-09-27 15:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-27 15:32 Gabriel Goller [this message]
2023-09-27 15:44 ` Thomas Lamprecht
2023-09-27 16:24 ` Thomas Lamprecht
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=20230927153227.256298-1-g.goller@proxmox.com \
--to=g.goller@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