[pbs-devel] [PATCH proxmox-backup v3] fix #4343: updated `view_task_result` to bail on task failure
Thomas Lamprecht
t.lamprecht at proxmox.com
Wed Sep 27 16:38:35 CEST 2023
Am 08/09/2023 um 15: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.
> index 0bbb928d..709d0d08 100644
> --- a/pbs-client/src/task_log.rs
> +++ b/pbs-client/src/task_log.rs
> @@ -96,6 +96,14 @@ 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")
> + && status_result["data"]["exitstatus"].as_str() != Some("OK")
> + {
> + bail!("task failed");
Hmm, while writing the changelog for a next bump I noticed that this
will now also exit with a failure-code when there are "only" warnings.
Did you think about that case?
Should we at least exit with different codes? I.e., so that tooling can
differentiate between error, meaning complete failure, and warnings,
meaning task probably did its main job, but something (recoverable) was
off.
IMO one could also argue that it would be sensible to exit with SUCCESS
(0) even on warnings, as after all warnings should be only returned if
the main job of the task was still successful, but, e.g., some
deprecated config option was set or the like.
More information about the pbs-devel
mailing list