Skip to content

Commit 4774e29

Browse files
committed
show global error if available
1 parent 627ba61 commit 4774e29

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/Thruk/Action/AddDefaults.pm

+9
Original file line numberDiff line numberDiff line change
@@ -514,13 +514,15 @@ sub add_defaults {
514514

515515
###############################
516516
my $safe_defaults_added_already;
517+
$c->stash->{'data_source_error'} = "";
517518
if(!$c->config->{'_lmd_federation_checked'} && ($ENV{'THRUK_USE_LMD'} || $c->config->{'lmd_remote'})) {
518519
# required on first run to expand federation peers
519520
eval {
520521
$c->db->reset_failed_backends($c);
521522
set_processinfo($c, ADD_SAFE_DEFAULTS, $cached_data);
522523
$safe_defaults_added_already = 1;
523524
};
525+
$c->stash->{'data_source_error'} = $@ if $@;
524526
}
525527
my $disabled_backends = set_enabled_backends($c);
526528

@@ -552,13 +554,16 @@ sub add_defaults {
552554
sleep 1;
553555
}
554556
if($err) {
557+
$c->stash->{'data_source_error'} = $err;
555558
# index.html and some other pages should not be redirect to the error page on backend errors
556559
set_possible_backends($c, $disabled_backends);
557560
if(Thruk::Base->debug) {
558561
_warn("data source error: $err");
559562
} else {
560563
_debug("data source error: $err");
561564
}
565+
} else {
566+
$c->stash->{'data_source_error'} = "";
562567
}
563568
$c->stash->{'last_program_restart'} = $last_program_restart;
564569

@@ -913,6 +918,10 @@ sub _calculate_section_totals {
913918
if($backend_detail->{$pd}->{'last_error'}) {
914919
$last_error = $backend_detail->{$pd}->{'last_error'};
915920
}
921+
if($last_error eq 'OK' && $class eq 'DOWN' && $c->stash->{'data_source_error'}) {
922+
# might happen on global internal Manager.pm errors
923+
$last_error = $c->stash->{'data_source_error'};
924+
}
916925
$initial_backends->{$pd}->{'last_error'} = $last_error;
917926
}
918927
}

0 commit comments

Comments
 (0)