From: Miroslav Lichvar Date: Thu, 13 Mar 2025 14:55:32 +0000 (+0100) Subject: sources: improve no-selectable-sources log message X-Git-Tag: 4.7-pre1~34 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=274c1767f20b34000612ae594b6689709697c7f2;p=thirdparty%2Fchrony.git sources: improve no-selectable-sources log message Include the number of unreachable sources in the "Can't synchronise: no selectable sources" log message to provide a hint whether it might be a networking issue. --- diff --git a/sources.c b/sources.c index edd145a0..65326398 100644 --- a/sources.c +++ b/sources.c @@ -935,7 +935,7 @@ SRC_SelectSource(SRC_Instance updated_inst) struct timespec now, ref_time; int i, j, j1, j2, index, sel_prefer, n_endpoints, n_sel_sources, sel_req_source; int max_badstat_reach, max_badstat_reach_size, n_badstats_sources; - int max_sel_reach, max_sel_reach_size; + int max_sel_reach, max_sel_reach_size, n_unreach_sources; int depth, best_depth, trust_depth, best_trust_depth, n_sel_trust_sources; int combined, stratum, min_stratum, max_score_index; int orphan_stratum, orphan_source; @@ -964,6 +964,7 @@ SRC_SelectSource(SRC_Instance updated_inst) n_endpoints = 0; n_sel_sources = n_sel_trust_sources = 0; n_badstats_sources = 0; + n_unreach_sources = 0; sel_req_source = 0; max_sel_reach = max_badstat_reach = 0; max_sel_reach_size = max_badstat_reach_size = 0; @@ -986,6 +987,10 @@ SRC_SelectSource(SRC_Instance updated_inst) continue; } + /* Count unreachable sources for a warning message */ + if (sources[i]->reachability == 0) + n_unreach_sources++; + si = &sources[i]->sel_info; SST_GetSelectionData(sources[i]->stats, &now, &si->lo_limit, &si->hi_limit, &si->root_distance, @@ -1153,7 +1158,8 @@ SRC_SelectSource(SRC_Instance updated_inst) if (n_endpoints == 0) { /* No sources provided valid endpoints */ - unselect_selected_source(LOGS_INFO, "Can't synchronise: no selectable sources"); + unselect_selected_source(LOGS_INFO, "Can't synchronise: no selectable sources" + " (%d unreachable sources)", n_unreach_sources); return; } diff --git a/test/simulation/014-intermittent b/test/simulation/014-intermittent index 2f018ed0..4af574b7 100755 --- a/test/simulation/014-intermittent +++ b/test/simulation/014-intermittent @@ -22,7 +22,7 @@ run_test || test_fail check_chronyd_exit || test_fail check_sync || test_fail -check_log_messages "Can't.*no selectable sources" 9 10 || test_fail +check_log_messages "Can't.*no selectable sources (1 unreachable" 9 10 || test_fail check_log_messages "Selected source 192.168.123.1" 9 10 || test_fail # Pass every 20th request @@ -43,7 +43,7 @@ run_test || test_fail check_chronyd_exit || test_fail check_sync || test_fail -check_log_messages "Can't.*no selectable sources" 5 15 || test_fail +check_log_messages "Can't.*no selectable sources (1 unreachable" 5 15 || test_fail check_log_messages "Selected source 192.168.123.1" 5 15 || test_fail test_pass