]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: resolvers: shut the warning when "default" resolvers is implicit
authorWilliam Lallemand <wlallemand@haproxy.org>
Wed, 24 Aug 2022 12:50:32 +0000 (14:50 +0200)
committerWilliam Lallemand <wlallemand@haproxy.org>
Wed, 24 Aug 2022 12:56:42 +0000 (14:56 +0200)
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
src/resolvers.c

index dc1381b5c41e2c1b10f9da946d1008e8ab557d57..b7274630c4198b78b4a7a2866436d73420aabc9d 100644 (file)
@@ -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 */
 };
 
index bcfd8783a24fc6d61bb02de4d83f8faadb39f29e..1f894ab48099c1bd9804ac08a1bd19df69f4b47d 100644 (file)
@@ -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", "<internal>", 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;