* [pbs-devel] [PATCH proxmox-backup v4] fix #4343: updated `view_task_result` to bail on task failure
@ 2023-09-27 15:32 Gabriel Goller
2023-09-27 15:44 ` Thomas Lamprecht
0 siblings, 1 reply; 3+ messages in thread
From: Gabriel Goller @ 2023-09-27 15:32 UTC (permalink / raw)
To: pbs-devel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pbs-devel] [PATCH proxmox-backup v4] fix #4343: updated `view_task_result` to bail on task failure
2023-09-27 15:32 [pbs-devel] [PATCH proxmox-backup v4] fix #4343: updated `view_task_result` to bail on task failure Gabriel Goller
@ 2023-09-27 15:44 ` Thomas Lamprecht
2023-09-27 16:24 ` Thomas Lamprecht
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Lamprecht @ 2023-09-27 15:44 UTC (permalink / raw)
To: Proxmox Backup Server development discussion, Gabriel Goller
Am 27/09/2023 um 17:32 schrieb Gabriel Goller:
> 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
>
note that v3 was applied already, so you'd need to send the changes
on top of that, i.e., rebase this to current master.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pbs-devel] [PATCH proxmox-backup v4] fix #4343: updated `view_task_result` to bail on task failure
2023-09-27 15:44 ` Thomas Lamprecht
@ 2023-09-27 16:24 ` Thomas Lamprecht
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2023-09-27 16:24 UTC (permalink / raw)
To: Proxmox Backup Server development discussion, Gabriel Goller
Am 27/09/2023 um 17:44 schrieb Thomas Lamprecht:
> Am 27/09/2023 um 17:32 schrieb Gabriel Goller:
>> 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
>>
>
> note that v3 was applied already, so you'd need to send the changes
> on top of that, i.e., rebase this to current master.
>
FYI: I've done so now myself so that I can do the bump still today.
I also added a follow-up that (mostly) switches out the inner `if` with a
`match` and also fails in the case that there's no `exitstatus` returned
by the API, which should not happen for tasks that are reported as `stopped`
(I forgot to mention the last part in the commit message...).
thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-27 16:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-27 15:32 [pbs-devel] [PATCH proxmox-backup v4] fix #4343: updated `view_task_result` to bail on task failure Gabriel Goller
2023-09-27 15:44 ` Thomas Lamprecht
2023-09-27 16:24 ` Thomas Lamprecht
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