From 65e41a6a3b6ce1a7ceabd2da70b9a171647f82b0 Mon Sep 17 00:00:00 2001 From: jrushf1239k Date: Fri, 17 Feb 2017 16:34:33 +0000 Subject: [PATCH] TS-4747: make marking parent proxies down in hostdb configurable. (cherry picked from commit 2752c758fd480c1becd814f40ff53896d44b315b) Conflicts: doc/admin-guide/files/records.config.en.rst doc/developer-guide/api/functions/TSHttpOverridableConfig.en.rst lib/ts/apidefs.h.in mgmt/RecordsConfig.cc plugins/experimental/ts_lua/ts_lua_http_config.c proxy/InkAPI.cc proxy/InkAPITest.cc proxy/http/HttpConfig.cc proxy/http/HttpConfig.h --- doc/admin-guide/files/records.config.en.rst | 9 +++++++++ .../api/functions/TSHttpOverridableConfig.en.rst | 1 + lib/ts/apidefs.h.in | 1 + mgmt/RecordsConfig.cc | 4 +++- plugins/experimental/ts_lua/ts_lua_http_config.c | 2 ++ proxy/InkAPI.cc | 8 ++++++++ proxy/InkAPITest.cc | 1 + proxy/http/HttpConfig.cc | 2 ++ proxy/http/HttpConfig.h | 6 ++++++ proxy/http/HttpTransact.cc | 6 +++++- 10 files changed, 38 insertions(+), 2 deletions(-) diff --git a/doc/admin-guide/files/records.config.en.rst b/doc/admin-guide/files/records.config.en.rst index d78a140bf27..84b01e10662 100644 --- a/doc/admin-guide/files/records.config.en.rst +++ b/doc/admin-guide/files/records.config.en.rst @@ -1075,6 +1075,15 @@ Parent Proxy Configuration The timeout value (in seconds) for parent cache connection attempts. +.. 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 26c47ccd848..cbf840027eb 100644 --- a/doc/developer-guide/api/functions/TSHttpOverridableConfig.en.rst +++ b/doc/developer-guide/api/functions/TSHttpOverridableConfig.en.rst @@ -151,6 +151,7 @@ The following configurations (from ``records.config``) are overridable. | :ts:cv:`proxy.config.http.number_of_redirections` | :ts:cv:`proxy.config.http.cache.max_open_write_retries` | :ts:cv:`proxy.config.http.redirect_use_orig_cache_key` +| :ts:cv:`proxy.config.http.parent_proxy.mark_down_hostdb` Examples ======== diff --git a/lib/ts/apidefs.h.in b/lib/ts/apidefs.h.in index 1ade5f6ef15..6ab3d98abde 100644 --- a/lib/ts/apidefs.h.in +++ b/lib/ts/apidefs.h.in @@ -681,6 +681,7 @@ typedef enum { TS_CONFIG_HTTP_UNCACHEABLE_REQUESTS_BYPASS_PARENT, TS_CONFIG_HTTP_PARENT_PROXY_TOTAL_CONNECT_ATTEMPTS, TS_CONFIG_HTTP_TRANSACTION_ACTIVE_TIMEOUT_IN, + TS_CONFIG_PARENT_FAILURES_UPDATE_HOSTDB, TS_CONFIG_LAST_ENTRY } TSOverridableConfigKey; diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc index d0fb027393f..6d852089b5d 100644 --- a/mgmt/RecordsConfig.cc +++ b/mgmt/RecordsConfig.cc @@ -517,7 +517,9 @@ static const RecordElement RecordsConfig[] = , {RECT_CONFIG, "proxy.config.http.parent_proxy.connect_attempts_timeout", RECD_INT, "30", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL} , - {RECT_CONFIG, "proxy.config.http.forward.proxy_auth_to_parent", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, 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 6b4256ba075..6aed5382413 100644 --- a/plugins/experimental/ts_lua/ts_lua_http_config.c +++ b/plugins/experimental/ts_lua/ts_lua_http_config.c @@ -120,6 +120,7 @@ typedef enum { TS_LUA_CONFIG_HTTP_PARENT_PROXY_TOTAL_CONNECT_ATTEMPTS = TS_CONFIG_HTTP_PARENT_PROXY_TOTAL_CONNECT_ATTEMPTS, TS_LUA_CONFIG_HTTP_TRANSACTION_ACTIVE_TIMEOUT_IN = TS_CONFIG_HTTP_TRANSACTION_ACTIVE_TIMEOUT_IN, TS_LUA_CONFIG_LAST_ENTRY = TS_CONFIG_LAST_ENTRY, + TS_LUA_CONFIG_PARENT_FAILURES_UPDATE_HOSTDB = TS_CONFIG_PARENT_FAILURES_UPDATE_HOSTDB, } TSLuaOverridableConfigKey; typedef enum { @@ -230,6 +231,7 @@ ts_lua_var_item ts_lua_http_config_vars[] = { TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_UNCACHEABLE_REQUESTS_BYPASS_PARENT), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_PARENT_PROXY_TOTAL_CONNECT_ATTEMPTS), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_TRANSACTION_ACTIVE_TIMEOUT_IN), + 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 578dcd46944..43ec6f184bf 100644 --- a/proxy/InkAPI.cc +++ b/proxy/InkAPI.cc @@ -7979,6 +7979,9 @@ _conf_to_memberp(TSOverridableConfigKey conf, OverridableHttpConfigParams *overr typ = OVERRIDABLE_TYPE_INT; ret = &overridableHttpConfig->transaction_active_timeout_in; 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: @@ -8521,6 +8524,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 e6beae14cf8..45f0f4ba590 100644 --- a/proxy/InkAPITest.cc +++ b/proxy/InkAPITest.cc @@ -7487,6 +7487,7 @@ const char *SDK_Overridable_Configs[TS_CONFIG_LAST_ENTRY] = { "proxy.config.http.uncacheable_requests_bypass_parent", "proxy.config.http.parent_proxy.total_connect_attempts", "proxy.config.http.transaction_active_timeout_in", + "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 4f78bae1397..22c3b4e4e3d 100644 --- a/proxy/http/HttpConfig.cc +++ b/proxy/http/HttpConfig.cc @@ -959,6 +959,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"); @@ -1232,6 +1233,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 b0466439867..56f2f4aebc7 100644 --- a/proxy/http/HttpConfig.h +++ b/proxy/http/HttpConfig.h @@ -402,6 +402,7 @@ struct OverridableHttpConfigParams { flow_control_enabled(0), accept_encoding_filter_enabled(0), normalize_ae_gzip(0), + parent_failures_update_hostdb(0), negative_caching_lifetime(1800), negative_revalidating_lifetime(1800), sock_recv_buffer_size_out(0), @@ -555,6 +556,11 @@ struct OverridableHttpConfigParams { //////////////////////////////// MgmtByte normalize_ae_gzip; + ////////////////////////// + // hostdb/dns variables // + ////////////////////////// + MgmtByte parent_failures_update_hostdb; + //////////////////////////////// // Negative cache lifetimes // //////////////////////////////// diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc index 2c09466f11c..3d00a457873 100644 --- a/proxy/http/HttpTransact.cc +++ b/proxy/http/HttpTransact.cc @@ -3603,7 +3603,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,