TT#135050 properly report rate-o-mat failure reason

the perl statement

  do $pl_file;

requires different handling in rate-o-mat launchers
in order to propagate the orignating error properly.

Change-Id: Ie1496236be62c4f6fc5767492ece8607dc179aa0
mr10.0.1
Rene Krenn 4 years ago
parent a8778bb2b4
commit dd1749e53e

@ -2032,8 +2032,7 @@ sub get_unrated_cdrs {
my $r_cdrs = shift;
my $sth = $sth_unrated_cdrs;
$sth->execute
or FATAL "Error executing unrated cdr statement: ".$sth->errstr;
$sth->execute or die("Error executing unrated cdr statement: ".$sth->errstr);
my @cdrs = ();
@ -2061,7 +2060,7 @@ sub get_unrated_cdrs {
and ($cdr->{id} % 4) == 2)
);
} else {
FATAL "Unknown hostname '$nodename'";
die("Unknown hostname '$nodename'");
}
check_shutdown() and return 0;
}
@ -2069,8 +2068,7 @@ sub get_unrated_cdrs {
# the while above may have been interrupted because there is no
# data left, or because there was an error. To decide what
# happened, we have to query $sth->err()
FATAL "Error fetching unrated cdr's: ". $sth->errstr
if $sth->err;
die("Error fetching unrated cdr's: ". $sth->errstr) if $sth->err;
$sth->finish;
if ($shuffle_batch) {
@ -3604,7 +3602,7 @@ sub main {
};
$error = $@;
if ($error) {
if ($DBI::err == 2006) {
if ($DBI::err and $DBI::err == 2006) {
INFO "DB connection gone, retrying...";
close_db();
$init = 1;

@ -101,8 +101,15 @@ sub run_rateomat {
kill 'HUP', 0;
} if defined $timeout;
alarm $timeout if defined $timeout;
die($!) if !defined do $rateomat_pl;
my $res = do $rateomat_pl;
alarm 0 if defined $timeout;
if ($@) {
diag("rate-o-mat: " . $@);
return 0;
} elsif (not $res) {
diag("rate-o-mat: " . $!);
return 0;
}
return 1;
};
alarm 0 if defined $timeout;
@ -126,13 +133,13 @@ sub run_rateomat_threads {
diag("timeout for rate-o-mat thread $tid");
threads->exit();
} if defined $timeout;
eval {
die($!) if !defined do $rateomat_pl;
return 1;
};
my $res = do $rateomat_pl;
if ($@) {
diag("rate-o-mat thread $tid: " . $@);
return 0;
} elsif (not $res) {
diag("rate-o-mat thread $tid: " . $!);
return 0;
}
return 1;
}));

Loading…
Cancel
Save