[pve-devel] [PATCH manager 3/3] jobs: rename function to better distinguish job state and task status

Fabian Ebner f.ebner at proxmox.com
Thu Nov 11 16:17:45 CET 2021


Also, default to 'internal error' if the task status within the lock
is undef, which shouldn't actually be possible.

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 PVE/Jobs.pm | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/PVE/Jobs.pm b/PVE/Jobs.pm
index bfccf7f1..b91d6158 100644
--- a/PVE/Jobs.pm
+++ b/PVE/Jobs.pm
@@ -54,7 +54,7 @@ sub lock_job_state {
     return $res;
 }
 
-my $get_job_status = sub {
+my $get_job_task_status = sub {
     my ($state) = @_;
 
     if (!defined($state->{upid})) {
@@ -82,17 +82,15 @@ sub update_job_stopped {
     my $state = read_job_state($jobid, $type);
     return if !defined($state) || $state->{state} ne 'started'; # removed or not started
 
-    if (defined($get_job_status->($state))) {
+    if (defined($get_job_task_status->($state))) {
 	lock_job_state($jobid, $type, sub {
 	    my $state = read_job_state($jobid, $type);
 	    return if !defined($state) || $state->{state} ne 'started'; # removed or not started
 
-	    my $status = $get_job_status->($state);
-
 	    my $new_state = {
 		state => 'stopped',
-		msg => $status,
-		upid => $state->{upid}
+		msg => $get_job_task_status->($state) // 'internal error',
+		upid => $state->{upid},
 	    };
 
 	    if ($state->{updated}) { # save updated time stamp
-- 
2.30.2






More information about the pve-devel mailing list