From 7786e43d68131727f6d149baa4af3afad655df7a Mon Sep 17 00:00:00 2001 From: John Rushford Date: Fri, 17 Dec 2021 17:35:10 +0000 Subject: [PATCH] Adds two overridable config variables to control parent mark downs. These configs may be overridden by the header_rewrite plugin on a per remap basis. - proxy.config.http.parent_proxy.enable_parent_timeout_markdowns is used to enable parent markdowns when an inactivity timeout triggers on a parent proxy. The default is disabled or '0'. - proxy.config.http.parent_proxy.disable_parent_markdowns is used to disable all parent proxy markdowns. The default is disabled or '0'. --- doc/admin-guide/files/records.config.en.rst | 26 +++++++++++++++++++++ include/ts/apidefs.h.in | 2 ++ mgmt/RecordsConfig.cc | 4 ++++ plugins/lua/ts_lua_http_config.c | 4 ++++ proxy/http/HttpConfig.cc | 25 ++++++++++++-------- proxy/http/HttpConfig.h | 12 ++++++---- proxy/http/HttpTransact.cc | 16 +++++++++++-- src/shared/overridable_txn_vars.cc | 6 ++++- src/traffic_server/InkAPI.cc | 6 +++++ src/traffic_server/InkAPITest.cc | 4 +++- 10 files changed, 86 insertions(+), 19 deletions(-) diff --git a/doc/admin-guide/files/records.config.en.rst b/doc/admin-guide/files/records.config.en.rst index f9141d74435..3c5445b03ea 100644 --- a/doc/admin-guide/files/records.config.en.rst +++ b/doc/admin-guide/files/records.config.en.rst @@ -1347,6 +1347,32 @@ Parent Proxy Configuration ``2`` Mark the host down. This is the default. ===== ====================================================================== +.. ts:cv:: CONFIG proxy.config.http.parent_proxy.enable_parent_timeout_markdowns INT 0 + :reloadable: + :overridable: + + Enables (``1``) or disables (``0``) parent proxy mark downs due to inactivity + timeouts. By default parent proxies are not marked down due to inactivity + timeouts, the transaction will retry using another parent instead. The + default for this configuration keeps this behavior and is disabled (``0``). + This setting is overridable using one of the two plugins ``header_rewrite`` + or ``conf_remap`` to enable inactivity timeout markdowns and should be done + so rather than enabling this globally. This setting should not be used in + conjunction with ``proxy.config.http.parent_proxy.disable_parent_markdowns`` + +.. ts:cv:: CONFIG proxy.config.http.parent_proxy.disable_parent_markdowns INT 0 + :reloadable: + :overridable: + + Enables (``1``) or disables (``0``) parent proxy markdowns. This is useful + if parent entries in a parent.config line are VIP's and one doesn't wish + to mark down a VIP which may have several origin or parent proxies behind + the load balancer. This setting is overridable using one of the + ``header_rewrite`` or the ``conf_remap`` plugins to override the default + setting and this method should be used rather than disabling markdowns + globally. This setting should not be used in conjunction with + ``proxy.config.http.parent_proxy.enable_parent_timeout_markdowns`` + HTTP Connection Timeouts ======================== diff --git a/include/ts/apidefs.h.in b/include/ts/apidefs.h.in index bf5b3144496..e3ebe46528d 100644 --- a/include/ts/apidefs.h.in +++ b/include/ts/apidefs.h.in @@ -867,6 +867,8 @@ typedef enum { TS_CONFIG_PLUGIN_VC_DEFAULT_BUFFER_WATER_MARK, TS_CONFIG_NET_SOCK_NOTSENT_LOWAT, TS_CONFIG_BODY_FACTORY_RESPONSE_SUPPRESSION_MODE, + TS_CONFIG_HTTP_ENABLE_PARENT_TIMEOUT_MARKDOWNS, + TS_CONFIG_HTTP_DISABLE_PARENT_MARKDOWNS, TS_CONFIG_LAST_ENTRY } TSOverridableConfigKey; diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc index 752133d5f51..9826d755377 100644 --- a/mgmt/RecordsConfig.cc +++ b/mgmt/RecordsConfig.cc @@ -451,6 +451,10 @@ static const RecordElement RecordsConfig[] = , {RECT_CONFIG, "proxy.config.http.parent_proxy.self_detect", RECD_INT, "2", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL} , + {RECT_CONFIG, "proxy.config.http.parent_proxy.enable_parent_timeout_markdowns", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL} + , + {RECT_CONFIG, "proxy.config.http.parent_proxy.disable_parent_markdowns", 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/lua/ts_lua_http_config.c b/plugins/lua/ts_lua_http_config.c index 310b068b1c5..9d5463a70ae 100644 --- a/plugins/lua/ts_lua_http_config.c +++ b/plugins/lua/ts_lua_http_config.c @@ -143,6 +143,8 @@ typedef enum { TS_LUA_CONFIG_PLUGIN_VC_DEFAULT_BUFFER_WATER_MARK = TS_CONFIG_PLUGIN_VC_DEFAULT_BUFFER_WATER_MARK, TS_LUA_CONFIG_NET_SOCK_NOTSENT_LOWAT = TS_CONFIG_NET_SOCK_NOTSENT_LOWAT, TS_LUA_CONFIG_BODY_FACTORY_RESPONSE_SUPPRESSION_MODE = TS_CONFIG_BODY_FACTORY_RESPONSE_SUPPRESSION_MODE, + TS_LUA_CONFIG_ENABLE_PARENT_TIMEOUT_MARKDOWNS = TS_CONFIG_HTTP_ENABLE_PARENT_TIMEOUT_MARKDOWNS, + TS_LUA_CONFIG_DISABLE_PARENT_MARKDOWNS = TS_CONFIG_HTTP_DISABLE_PARENT_MARKDOWNS, TS_LUA_CONFIG_LAST_ENTRY = TS_CONFIG_LAST_ENTRY, } TSLuaOverridableConfigKey; @@ -278,6 +280,8 @@ ts_lua_var_item ts_lua_http_config_vars[] = { TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_PLUGIN_VC_DEFAULT_BUFFER_WATER_MARK), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_NET_SOCK_NOTSENT_LOWAT), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_BODY_FACTORY_RESPONSE_SUPPRESSION_MODE), + TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_ENABLE_PARENT_TIMEOUT_MARKDOWNS), + TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_DISABLE_PARENT_MARKDOWNS), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_LAST_ENTRY), }; diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc index 07ed442d3f8..c1d8c4618bc 100644 --- a/proxy/http/HttpConfig.cc +++ b/proxy/http/HttpConfig.cc @@ -1250,6 +1250,9 @@ HttpConfig::startup() "proxy.config.http.parent_proxy.per_parent_connect_attempts"); HttpEstablishStaticConfigLongLong(c.oride.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"); + HttpEstablishStaticConfigByte(c.oride.enable_parent_timeout_markdowns, + "proxy.config.http.parent_proxy.enable_parent_timeout_markdowns"); + HttpEstablishStaticConfigByte(c.oride.disable_parent_markdowns, "proxy.config.http.parent_proxy.disable_parent_markdowns"); 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"); @@ -1535,16 +1538,18 @@ HttpConfig::reconfigure() "will never redispatch to another server", m_master.oride.connect_attempts_rr_retries, params->oride.connect_attempts_max_retries); } - params->oride.connect_attempts_rr_retries = m_master.oride.connect_attempts_rr_retries; - params->oride.connect_attempts_timeout = m_master.oride.connect_attempts_timeout; - params->oride.connect_dead_policy = m_master.oride.connect_dead_policy; - params->oride.post_connect_attempts_timeout = m_master.oride.post_connect_attempts_timeout; - params->oride.parent_connect_attempts = m_master.oride.parent_connect_attempts; - params->oride.parent_retry_time = m_master.oride.parent_retry_time; - params->oride.parent_fail_threshold = m_master.oride.parent_fail_threshold; - params->oride.per_parent_connect_attempts = m_master.oride.per_parent_connect_attempts; - params->oride.parent_connect_timeout = m_master.oride.parent_connect_timeout; - params->oride.parent_failures_update_hostdb = m_master.oride.parent_failures_update_hostdb; + params->oride.connect_attempts_rr_retries = m_master.oride.connect_attempts_rr_retries; + params->oride.connect_attempts_timeout = m_master.oride.connect_attempts_timeout; + params->oride.connect_dead_policy = m_master.oride.connect_dead_policy; + params->oride.post_connect_attempts_timeout = m_master.oride.post_connect_attempts_timeout; + params->oride.parent_connect_attempts = m_master.oride.parent_connect_attempts; + params->oride.parent_retry_time = m_master.oride.parent_retry_time; + params->oride.parent_fail_threshold = m_master.oride.parent_fail_threshold; + params->oride.per_parent_connect_attempts = m_master.oride.per_parent_connect_attempts; + params->oride.parent_connect_timeout = m_master.oride.parent_connect_timeout; + params->oride.parent_failures_update_hostdb = m_master.oride.parent_failures_update_hostdb; + params->oride.enable_parent_timeout_markdowns = m_master.oride.enable_parent_timeout_markdowns; + params->oride.disable_parent_markdowns = m_master.oride.disable_parent_markdowns; 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 a47dea615ab..eed48015d34 100644 --- a/proxy/http/HttpConfig.h +++ b/proxy/http/HttpConfig.h @@ -678,11 +678,13 @@ struct OverridableHttpConfigParams { //////////////////////////////////// // parent proxy connect attempts // /////////////////////////////////// - MgmtInt parent_connect_attempts = 4; - MgmtInt parent_retry_time = 300; - MgmtInt parent_fail_threshold = 10; - MgmtInt per_parent_connect_attempts = 2; - MgmtInt parent_connect_timeout = 30; + MgmtInt parent_connect_attempts = 4; + MgmtInt parent_retry_time = 300; + MgmtInt parent_fail_threshold = 10; + MgmtInt per_parent_connect_attempts = 2; + MgmtInt parent_connect_timeout = 30; + MgmtByte enable_parent_timeout_markdowns = 0; + MgmtByte disable_parent_markdowns = 0; MgmtInt down_server_timeout = 300; MgmtInt client_abort_threshold = 1000; diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc index b8903c80ef1..bf795779b1d 100644 --- a/proxy/http/HttpTransact.cc +++ b/proxy/http/HttpTransact.cc @@ -214,6 +214,18 @@ markParentDown(HttpTransact::State *s) HTTP_INCREMENT_DYN_STAT(http_total_parent_marked_down_count); url_mapping *mp = s->url_map.getMapping(); + TxnDebug("http_trans", "sm_id[%" PRId64 "] enable_parent_timeout_markdowns: %d, disable_parent_markdowns: %d", + s->state_machine->sm_id, s->txn_conf->enable_parent_timeout_markdowns, s->txn_conf->disable_parent_markdowns); + + if (s->txn_conf->disable_parent_markdowns == 1) { + TxnDebug("http_trans", "parent markdowns are disabled for this request"); + return; + } + + if (s->current.state == HttpTransact::INACTIVE_TIMEOUT && s->txn_conf->enable_parent_timeout_markdowns == 0) { + return; + } + if (s->response_action.handled) { // Do nothing. If a plugin handled the response, let it handle markdown. } else if (mp && mp->strategy) { @@ -3702,7 +3714,7 @@ HttpTransact::handle_response_from_parent(State *s) // Only mark the parent down if we failed to connect // to the parent otherwise slow origin servers cause // us to mark the parent down - if (s->current.state == CONNECTION_ERROR) { + if (s->current.state == CONNECTION_ERROR || s->current.state == INACTIVE_TIMEOUT) { markParentDown(s); } // We are done so look for another parent if any @@ -3713,7 +3725,7 @@ HttpTransact::handle_response_from_parent(State *s) // appropriate HTTP_INCREMENT_DYN_STAT(http_total_parent_retries_exhausted_stat); TxnDebug("http_trans", "[handle_response_from_parent] Error. No more retries."); - if (s->current.state == CONNECTION_ERROR) { + if (s->current.state == CONNECTION_ERROR || s->current.state == INACTIVE_TIMEOUT) { markParentDown(s); } s->parent_result.result = PARENT_FAIL; diff --git a/src/shared/overridable_txn_vars.cc b/src/shared/overridable_txn_vars.cc index 906de8ec1a6..5b6f3db5817 100644 --- a/src/shared/overridable_txn_vars.cc +++ b/src/shared/overridable_txn_vars.cc @@ -168,4 +168,8 @@ const std::unordered_mapresponse_suppression_mode, conv); break; + case TS_CONFIG_HTTP_ENABLE_PARENT_TIMEOUT_MARKDOWNS: + ret = _memberp_to_generic(&overridableHttpConfig->enable_parent_timeout_markdowns, conv); + break; + case TS_CONFIG_HTTP_DISABLE_PARENT_MARKDOWNS: + ret = _memberp_to_generic(&overridableHttpConfig->disable_parent_markdowns, conv); + break; // This helps avoiding compiler warnings, yet detect unhandled enum members. case TS_CONFIG_NULL: diff --git a/src/traffic_server/InkAPITest.cc b/src/traffic_server/InkAPITest.cc index 1a7897b8160..62d452033de 100644 --- a/src/traffic_server/InkAPITest.cc +++ b/src/traffic_server/InkAPITest.cc @@ -8698,7 +8698,9 @@ std::array SDK_Overridable_Configs = { "proxy.config.plugin.vc.default_buffer_index", "proxy.config.plugin.vc.default_buffer_water_mark", "proxy.config.net.sock_notsent_lowat", - "proxy.config.body_factory.response_suppression_mode"}}; + "proxy.config.body_factory.response_suppression_mode", + "proxy.config.http.parent_proxy.enable_parent_timeout_markdowns", + "proxy.config.http.parent_proxy.disable_parent_markdowns"}}; extern ClassAllocator httpSMAllocator;