]> git.proxmox.com Git - pve-common.git/commitdiff
tools: add upid_status_is_error function
authorFabian Ebner <f.ebner@proxmox.com>
Wed, 12 May 2021 12:32:50 +0000 (14:32 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 17 Jun 2021 13:22:56 +0000 (15:22 +0200)
There's also support for ending a task with warnings now, so the logic "status
not 'OK' means error" does not work anymore.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
src/PVE/Tools.pm

index 465c338375d8bc652f4d32ecc75e6b4b37a6e39d..8946e93c6c1f1d8c22cf87533a1eb3cc2abe6a51 100644 (file)
@@ -1171,6 +1171,14 @@ sub upid_read_status {
     return "unable to read tail (got $br bytes)";
 }
 
+# Check if the status returned by upid_read_status is an error status.
+# If the status could not be parsed it's also treated as an error.
+sub upid_status_is_error {
+    my ($status) = @_;
+
+    return !($status eq 'OK' || $status =~ m/^WARNINGS: \d+$/);
+}
+
 # useful functions to store comments in config files
 sub encode_text {
     my ($text) = @_;