diff --git a/doc/admin-guide/files/records.config.en.rst b/doc/admin-guide/files/records.config.en.rst index d7a90b3d19c..cc71ec035fe 100644 --- a/doc/admin-guide/files/records.config.en.rst +++ b/doc/admin-guide/files/records.config.en.rst @@ -1273,6 +1273,15 @@ Parent Proxy Configuration See :ref:`admin-performance-timeouts` for more discussion on |TS| timeouts. +.. ts:cv:: CONFIG proxy.config.http.parent_proxy.mark_down_hostdb INT 0 + :reloadable: + :overridable: + + Enables (``1``) or disables (``0``) marking parent proxies down in hostdb when a connection + error is detected. Normally parent selection manages parent proxies and will mark them as unavailable + as needed. But when parents are defined in dns with multiple ip addresses, it may be useful to mark the + failing ip down in hostdb. In this case you would enable these updates. + .. ts:cv:: CONFIG proxy.config.http.forward.proxy_auth_to_parent INT 0 :reloadable: :overridable: diff --git a/doc/developer-guide/api/functions/TSHttpOverridableConfig.en.rst b/doc/developer-guide/api/functions/TSHttpOverridableConfig.en.rst index d0bd6d86d01..3fce26075b6 100644 --- a/doc/developer-guide/api/functions/TSHttpOverridableConfig.en.rst +++ b/doc/developer-guide/api/functions/TSHttpOverridableConfig.en.rst @@ -140,6 +140,7 @@ c:member:`TS_CONFIG_HTTP_NUMBER_OF_REDIRECTIONS` :ts:cv:`prox c:member:`TS_CONFIG_HTTP_ORIGIN_MAX_CONNECTIONS` :ts:cv:`proxy.config.http.origin_max_connections` c:member:`TS_CONFIG_HTTP_ORIGIN_MAX_CONNECTIONS_QUEUE` :ts:cv:`proxy.config.http.origin_max_connections_queue` c:member:`TS_CONFIG_HTTP_PARENT_PROXY_TOTAL_CONNECT_ATTEMPTS` :ts:cv:`proxy.config.http.parent_proxy.total_connect_attempts` +c:member:`TS_CONFIG_PARENT_FAILURES_UPDATE_HOSTDB` :ts:cv:`proxy.config.http.parent_proxy.mark_down_hostdb` c:member:`TS_CONFIG_HTTP_POST_CHECK_CONTENT_LENGTH_ENABLED` :ts:cv:`proxy.config.http.post.check.content_length.enabled` c:member:`TS_CONFIG_HTTP_POST_CONNECT_ATTEMPTS_TIMEOUT` :ts:cv:`proxy.config.http.post_connect_attempts_timeout` c:member:`TS_CONFIG_HTTP_REDIRECT_USE_ORIG_CACHE_KEY` :ts:cv:`proxy.config.http.redirect_use_orig_cache_key` diff --git a/lib/ts/apidefs.h.in b/lib/ts/apidefs.h.in index dcf6d0e83d7..d38acb618a3 100644 --- a/lib/ts/apidefs.h.in +++ b/lib/ts/apidefs.h.in @@ -745,6 +745,7 @@ typedef enum { TS_CONFIG_HTTP_FORWARD_CONNECT_METHOD, TS_CONFIG_SSL_CERT_FILENAME, TS_CONFIG_SSL_CERT_FILEPATH, + TS_CONFIG_PARENT_FAILURES_UPDATE_HOSTDB, TS_CONFIG_LAST_ENTRY } TSOverridableConfigKey; diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc index 3569a6e8782..f9efa96c7aa 100644 --- a/mgmt/RecordsConfig.cc +++ b/mgmt/RecordsConfig.cc @@ -518,6 +518,8 @@ static const RecordElement RecordsConfig[] = , {RECT_CONFIG, "proxy.config.http.parent_proxy.connect_attempts_timeout", RECD_INT, "30", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL} , + {RECT_CONFIG, "proxy.config.http.parent_proxy.mark_down_hostdb", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL} + , {RECT_CONFIG, "proxy.config.http.forward.proxy_auth_to_parent", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL} , diff --git a/plugins/experimental/ts_lua/ts_lua_http_config.c b/plugins/experimental/ts_lua/ts_lua_http_config.c index b3eedd382d3..591a88a48a4 100644 --- a/plugins/experimental/ts_lua/ts_lua_http_config.c +++ b/plugins/experimental/ts_lua/ts_lua_http_config.c @@ -124,6 +124,7 @@ typedef enum { TS_LUA_CONFIG_HTTP_FORWARD_CONNECT_METHOD = TS_CONFIG_HTTP_FORWARD_CONNECT_METHOD, TS_LUA_CONFIG_SSL_CERT_FILENAME = TS_CONFIG_SSL_CERT_FILENAME, TS_LUA_CONFIG_SSL_CERT_FILEPATH = TS_CONFIG_SSL_CERT_FILEPATH, + TS_LUA_CONFIG_PARENT_FAILURES_UPDATE_HOSTDB = TS_CONFIG_PARENT_FAILURES_UPDATE_HOSTDB, } TSLuaOverridableConfigKey; typedef enum { @@ -238,6 +239,7 @@ ts_lua_var_item ts_lua_http_config_vars[] = { TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_FORWARD_CONNECT_METHOD), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_SSL_CERT_FILENAME), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_SSL_CERT_FILEPATH), + TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_PARENT_FAILURES_UPDATE_HOSTDB), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_LAST_ENTRY), }; diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc index 21255b58384..466a92b042f 100644 --- a/proxy/InkAPI.cc +++ b/proxy/InkAPI.cc @@ -8150,6 +8150,9 @@ _conf_to_memberp(TSOverridableConfigKey conf, OverridableHttpConfigParams *overr typ = OVERRIDABLE_TYPE_STRING; ret = &overridableHttpConfig->client_cert_filepath; break; + case TS_CONFIG_PARENT_FAILURES_UPDATE_HOSTDB: + ret = &overridableHttpConfig->parent_failures_update_hostdb; + break; // This helps avoiding compiler warnings, yet detect unhandled enum members. case TS_CONFIG_NULL: case TS_CONFIG_LAST_ENTRY: @@ -8769,6 +8772,11 @@ TSHttpTxnConfigFind(const char *name, int length, TSOverridableConfigKey *conf, case 47: switch (name[length - 1]) { + case 'b': + if (!strncmp(name, "proxy.config.http.parent_proxy.mark_down_hostdb", length)) { + cnf = TS_CONFIG_PARENT_FAILURES_UPDATE_HOSTDB; + } + break; case 'd': if (!strncmp(name, "proxy.config.http.negative_revalidating_enabled", length)) { cnf = TS_CONFIG_HTTP_NEGATIVE_REVALIDATING_ENABLED; diff --git a/proxy/InkAPITest.cc b/proxy/InkAPITest.cc index 6978c05d59d..55c56d50ad9 100644 --- a/proxy/InkAPITest.cc +++ b/proxy/InkAPITest.cc @@ -7621,6 +7621,7 @@ const char *SDK_Overridable_Configs[TS_CONFIG_LAST_ENTRY] = { "proxy.config.http.forward_connect_method", "proxy.config.ssl.client.cert.filename", "proxy.config.ssl.client.cert.path", + "proxy.config.http.parent_proxy.mark_down_hostdb", }; REGRESSION_TEST(SDK_API_OVERRIDABLE_CONFIGS)(RegressionTest *test, int /* atype ATS_UNUSED */, int *pstatus) diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc index 09e41318ea2..a452d199e63 100644 --- a/proxy/http/HttpConfig.cc +++ b/proxy/http/HttpConfig.cc @@ -972,6 +972,7 @@ HttpConfig::startup() HttpEstablishStaticConfigLongLong(c.oride.parent_connect_attempts, "proxy.config.http.parent_proxy.total_connect_attempts"); HttpEstablishStaticConfigLongLong(c.per_parent_connect_attempts, "proxy.config.http.parent_proxy.per_parent_connect_attempts"); HttpEstablishStaticConfigLongLong(c.parent_connect_timeout, "proxy.config.http.parent_proxy.connect_attempts_timeout"); + HttpEstablishStaticConfigByte(c.oride.parent_failures_update_hostdb, "proxy.config.http.parent_proxy.mark_down_hostdb"); HttpEstablishStaticConfigLongLong(c.oride.sock_recv_buffer_size_out, "proxy.config.net.sock_recv_buffer_size_out"); HttpEstablishStaticConfigLongLong(c.oride.sock_send_buffer_size_out, "proxy.config.net.sock_send_buffer_size_out"); @@ -1255,6 +1256,7 @@ HttpConfig::reconfigure() params->oride.parent_connect_attempts = m_master.oride.parent_connect_attempts; params->per_parent_connect_attempts = m_master.per_parent_connect_attempts; params->parent_connect_timeout = m_master.parent_connect_timeout; + params->oride.parent_failures_update_hostdb = m_master.oride.parent_failures_update_hostdb; params->oride.sock_recv_buffer_size_out = m_master.oride.sock_recv_buffer_size_out; params->oride.sock_send_buffer_size_out = m_master.oride.sock_send_buffer_size_out; diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h index fb69090d9a5..e3c6c52673c 100644 --- a/proxy/http/HttpConfig.h +++ b/proxy/http/HttpConfig.h @@ -410,6 +410,7 @@ struct OverridableHttpConfigParams { flow_control_enabled(0), normalize_ae_gzip(0), srv_enabled(0), + parent_failures_update_hostdb(0), cache_open_write_fail_action(0), post_check_content_length_enabled(1), redirection_enabled(0), @@ -563,6 +564,7 @@ struct OverridableHttpConfigParams { // hostdb/dns variables // ////////////////////////// MgmtByte srv_enabled; + MgmtByte parent_failures_update_hostdb; MgmtByte cache_open_write_fail_action; diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc index 3b05a91d3ec..480075338cf 100644 --- a/proxy/http/HttpTransact.cc +++ b/proxy/http/HttpTransact.cc @@ -3571,7 +3571,11 @@ HttpTransact::handle_response_from_parent(State *s) ink_assert(s->hdr_info.server_request.valid()); s->current.server->connect_result = ENOTCONN; - s->state_machine->do_hostdb_update_if_necessary(); + // only mark the parent down in hostdb if the configuration allows it, + // see proxy.config.http.parent_proxy.mark_down_hostdb in records.config. + if (s->txn_conf->parent_failures_update_hostdb) { + s->state_machine->do_hostdb_update_if_necessary(); + } char addrbuf[INET6_ADDRSTRLEN]; DebugTxn("http_trans", "[%d] failed to connect to parent %s", s->current.attempts,