Skip to content

Commit ebd0e8f

Browse files
committed
BUG/MINOR: promex: Skip resolvers metrics when there is no resolver section
By default, there is always at least on resolver section, the default one, based on "/etc/resolv.conf" content. However, it is possible to have no resolver at all if the file is empty or if any error occurred. Errors are silently ignored at this stage. In that case, there was a bug in the Prometheus exporter leading to a crash because the resolver section list is empty. An invalid resolver entity was used. To fix the issue we must only take care to not dump resolvers metrics when there is no resolver. Thanks to Aurelien to have spotted the offending commit. This patch should fix the issue #2604. It must be backported to 3.0. (cherry picked from commit 91fe085) Signed-off-by: Christopher Faulet <[email protected]>
1 parent abecd95 commit ebd0e8f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/resolvers.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3919,8 +3919,12 @@ static int rslv_promex_metric_info(unsigned int id, struct promex_metric *metric
39193919

39203920
static void *rslv_promex_start_ts(void *unused, unsigned int id)
39213921
{
3922-
struct resolvers *resolver = LIST_NEXT(&sec_resolvers, struct resolvers *, list);
3922+
struct resolvers *resolver;
39233923

3924+
if (LIST_ISEMPTY(&sec_resolvers))
3925+
return NULL;
3926+
3927+
resolver = LIST_NEXT(&sec_resolvers, struct resolvers *, list);
39243928
return LIST_NEXT(&resolver->nameservers, struct dns_nameserver *, list);
39253929
}
39263930

0 commit comments

Comments
 (0)