From 4ec19e8487bbb2e4cc0078b0d905f7bcd820e1fe Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Tue, 13 Jul 2021 18:47:05 +0200 Subject: [PATCH] api: services: improve state detection for one-shot units Signed-off-by: Thomas Lamprecht --- PVE/API2/Services.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/PVE/API2/Services.pm b/PVE/API2/Services.pm index d0280b09..e8d9f4ca 100644 --- a/PVE/API2/Services.pm +++ b/PVE/API2/Services.pm @@ -116,7 +116,12 @@ my $service_state = sub { if (my $err = $@) { return $res; } - $res->{state} = $ss->{SubState} || 'unknown'; + my $state = $ss->{SubState} || 'unknown'; + if ($state eq 'dead' && $ss->{Type} && $ss->{Type} eq 'oneshot' && $ss->{Result}) { + $res->{state} = $ss->{Result}; + } else { + $res->{state} = $ss->{SubState} || 'unknown'; + } $res->{'active-state'} = $ss->{ActiveState} || 'unknown'; $res->{'unit-state'} = $ss->{UnitFileState} || 'unknown';