[pve-devel] [PATCH manager 1/3] pvescheduler: catch errors in forked childs

Dominik Csapak d.csapak at proxmox.com
Thu Nov 18 14:28:29 CET 2021


if '$sub' dies, the error handler of PVE::Daemon triggers, which
initiates a shutdown of the child, resulting in confusing error logs
(e.g. 'got shutdown request, signal running jobs to stop')

instead, run it under 'eval' and print the error to the sylog instead

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 PVE/Service/pvescheduler.pm | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/PVE/Service/pvescheduler.pm b/PVE/Service/pvescheduler.pm
index 9f5c4515..d4f73702 100755
--- a/PVE/Service/pvescheduler.pm
+++ b/PVE/Service/pvescheduler.pm
@@ -47,7 +47,12 @@ sub run {
 	    die "fork failed: $!\n";
 	} elsif ($child == 0) {
 	    $self->after_fork_cleanup();
-	    $sub->();
+	    eval {
+		$sub->();
+	    };
+	    if (my $err = $@) {
+		syslog('err', "ERROR: $err");
+	    }
 	    POSIX::_exit(0);
 	}
 
-- 
2.30.2






More information about the pve-devel mailing list