From b10b1196b864b50bb1c781bd0064a1176467046f Mon Sep 17 00:00:00 2001 From: William Lallemand Date: Wed, 24 Aug 2022 14:50:32 +0200 Subject: [PATCH] MINOR: resolvers: shut the warning when "default" resolvers is implicit Shut the connect() warning of resolvers_finalize_config() when the configuration was not emitted manually. This shuts the warning for the "default" resolvers which is created automatically for the httpclient. Must be backported in 2.6. --- include/haproxy/resolvers-t.h | 1 + src/resolvers.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/haproxy/resolvers-t.h b/include/haproxy/resolvers-t.h index dc1381b5c4..b7274630c4 100644 --- a/include/haproxy/resolvers-t.h +++ b/include/haproxy/resolvers-t.h @@ -163,6 +163,7 @@ struct resolvers { struct { const char *file; /* file where the section appears */ int line; /* line where the section appears */ + int implicit; /* config was auto-generated and must be silent */ } conf; /* config information */ }; diff --git a/src/resolvers.c b/src/resolvers.c index bcfd8783a2..1f894ab480 100644 --- a/src/resolvers.c +++ b/src/resolvers.c @@ -2509,8 +2509,10 @@ static int resolvers_finalize_config(void) continue; } if (connect(fd, (struct sockaddr*)&ns->dgram->conn.addr.to, get_addr_len(&ns->dgram->conn.addr.to)) == -1) { - ha_warning("resolvers '%s': can't connect socket for nameserver '%s'.\n", - resolvers->id, ns->id); + if (!resolvers->conf.implicit) { /* emit a warning only if it was configured manually */ + ha_warning("resolvers '%s': can't connect socket for nameserver '%s'.\n", + resolvers->id, ns->id); + } close(fd); err_code |= ERR_WARN; continue; @@ -3682,6 +3684,9 @@ int resolvers_create_default() err_code |= resolvers_new(&curr_resolvers, "default", "", 0); if (err_code & ERR_CODE) goto err; + + curr_resolvers->conf.implicit = 1; + err_code |= parse_resolve_conf(NULL, NULL); if (err_code & ERR_CODE) goto err;