Skip to content

Commit 65e41a6

Browse files
jrushf1239kjrushf1239k
authored andcommitted
TS-4747: make marking parent proxies down in hostdb configurable.
(cherry picked from commit 2752c75) 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
1 parent 38fa0be commit 65e41a6

File tree

10 files changed

+38
-2
lines changed

10 files changed

+38
-2
lines changed

doc/admin-guide/files/records.config.en.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,15 @@ Parent Proxy Configuration
10751075

10761076
The timeout value (in seconds) for parent cache connection attempts.
10771077

1078+
.. ts:cv:: CONFIG proxy.config.http.parent_proxy.mark_down_hostdb INT 0
1079+
:reloadable:
1080+
:overridable:
1081+
1082+
Enables (``1``) or disables (``0``) marking parent proxies down in hostdb when a connection
1083+
error is detected. Normally parent selection manages parent proxies and will mark them as unavailable
1084+
as needed. But when parents are defined in dns with multiple ip addresses, it may be useful to mark the
1085+
failing ip down in hostdb. In this case you would enable these updates.
1086+
10781087
.. ts:cv:: CONFIG proxy.config.http.forward.proxy_auth_to_parent INT 0
10791088
:reloadable:
10801089
:overridable:

doc/developer-guide/api/functions/TSHttpOverridableConfig.en.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ The following configurations (from ``records.config``) are overridable.
151151
| :ts:cv:`proxy.config.http.number_of_redirections`
152152
| :ts:cv:`proxy.config.http.cache.max_open_write_retries`
153153
| :ts:cv:`proxy.config.http.redirect_use_orig_cache_key`
154+
| :ts:cv:`proxy.config.http.parent_proxy.mark_down_hostdb`
154155
155156
Examples
156157
========

lib/ts/apidefs.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,7 @@ typedef enum {
681681
TS_CONFIG_HTTP_UNCACHEABLE_REQUESTS_BYPASS_PARENT,
682682
TS_CONFIG_HTTP_PARENT_PROXY_TOTAL_CONNECT_ATTEMPTS,
683683
TS_CONFIG_HTTP_TRANSACTION_ACTIVE_TIMEOUT_IN,
684+
TS_CONFIG_PARENT_FAILURES_UPDATE_HOSTDB,
684685
TS_CONFIG_LAST_ENTRY
685686
} TSOverridableConfigKey;
686687

mgmt/RecordsConfig.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,9 @@ static const RecordElement RecordsConfig[] =
517517
,
518518
{RECT_CONFIG, "proxy.config.http.parent_proxy.connect_attempts_timeout", RECD_INT, "30", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL}
519519
,
520-
{RECT_CONFIG, "proxy.config.http.forward.proxy_auth_to_parent", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL}
520+
{RECT_CONFIG, "proxy.config.http.parent_proxy.mark_down_hostdb", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
521+
,
522+
{RECT_CONFIG, "proxy.config.http.forward.proxy_auth_to_parent", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
521523
,
522524

523525
// ###################################

plugins/experimental/ts_lua/ts_lua_http_config.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ typedef enum {
120120
TS_LUA_CONFIG_HTTP_PARENT_PROXY_TOTAL_CONNECT_ATTEMPTS = TS_CONFIG_HTTP_PARENT_PROXY_TOTAL_CONNECT_ATTEMPTS,
121121
TS_LUA_CONFIG_HTTP_TRANSACTION_ACTIVE_TIMEOUT_IN = TS_CONFIG_HTTP_TRANSACTION_ACTIVE_TIMEOUT_IN,
122122
TS_LUA_CONFIG_LAST_ENTRY = TS_CONFIG_LAST_ENTRY,
123+
TS_LUA_CONFIG_PARENT_FAILURES_UPDATE_HOSTDB = TS_CONFIG_PARENT_FAILURES_UPDATE_HOSTDB,
123124
} TSLuaOverridableConfigKey;
124125

125126
typedef enum {
@@ -230,6 +231,7 @@ ts_lua_var_item ts_lua_http_config_vars[] = {
230231
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_UNCACHEABLE_REQUESTS_BYPASS_PARENT),
231232
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_PARENT_PROXY_TOTAL_CONNECT_ATTEMPTS),
232233
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_TRANSACTION_ACTIVE_TIMEOUT_IN),
234+
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_PARENT_FAILURES_UPDATE_HOSTDB),
233235
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_LAST_ENTRY),
234236
};
235237

proxy/InkAPI.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7979,6 +7979,9 @@ _conf_to_memberp(TSOverridableConfigKey conf, OverridableHttpConfigParams *overr
79797979
typ = OVERRIDABLE_TYPE_INT;
79807980
ret = &overridableHttpConfig->transaction_active_timeout_in;
79817981
break;
7982+
case TS_CONFIG_PARENT_FAILURES_UPDATE_HOSTDB:
7983+
ret = &overridableHttpConfig->parent_failures_update_hostdb;
7984+
break;
79827985
// This helps avoiding compiler warnings, yet detect unhandled enum members.
79837986
case TS_CONFIG_NULL:
79847987
case TS_CONFIG_LAST_ENTRY:
@@ -8521,6 +8524,11 @@ TSHttpTxnConfigFind(const char *name, int length, TSOverridableConfigKey *conf,
85218524

85228525
case 47:
85238526
switch (name[length - 1]) {
8527+
case 'b':
8528+
if (!strncmp(name, "proxy.config.http.parent_proxy.mark_down_hostdb", length)) {
8529+
cnf = TS_CONFIG_PARENT_FAILURES_UPDATE_HOSTDB;
8530+
}
8531+
break;
85248532
case 'd':
85258533
if (!strncmp(name, "proxy.config.http.negative_revalidating_enabled", length))
85268534
cnf = TS_CONFIG_HTTP_NEGATIVE_REVALIDATING_ENABLED;

proxy/InkAPITest.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7487,6 +7487,7 @@ const char *SDK_Overridable_Configs[TS_CONFIG_LAST_ENTRY] = {
74877487
"proxy.config.http.uncacheable_requests_bypass_parent",
74887488
"proxy.config.http.parent_proxy.total_connect_attempts",
74897489
"proxy.config.http.transaction_active_timeout_in",
7490+
"proxy.config.http.parent_proxy.mark_down_hostdb",
74907491
};
74917492

74927493
REGRESSION_TEST(SDK_API_OVERRIDABLE_CONFIGS)(RegressionTest *test, int /* atype ATS_UNUSED */, int *pstatus)

proxy/http/HttpConfig.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,7 @@ HttpConfig::startup()
959959
HttpEstablishStaticConfigLongLong(c.oride.parent_connect_attempts, "proxy.config.http.parent_proxy.total_connect_attempts");
960960
HttpEstablishStaticConfigLongLong(c.per_parent_connect_attempts, "proxy.config.http.parent_proxy.per_parent_connect_attempts");
961961
HttpEstablishStaticConfigLongLong(c.parent_connect_timeout, "proxy.config.http.parent_proxy.connect_attempts_timeout");
962+
HttpEstablishStaticConfigByte(c.oride.parent_failures_update_hostdb, "proxy.config.http.parent_proxy.mark_down_hostdb");
962963

963964
HttpEstablishStaticConfigLongLong(c.oride.sock_recv_buffer_size_out, "proxy.config.net.sock_recv_buffer_size_out");
964965
HttpEstablishStaticConfigLongLong(c.oride.sock_send_buffer_size_out, "proxy.config.net.sock_send_buffer_size_out");
@@ -1232,6 +1233,7 @@ HttpConfig::reconfigure()
12321233
params->oride.parent_connect_attempts = m_master.oride.parent_connect_attempts;
12331234
params->per_parent_connect_attempts = m_master.per_parent_connect_attempts;
12341235
params->parent_connect_timeout = m_master.parent_connect_timeout;
1236+
params->oride.parent_failures_update_hostdb = m_master.oride.parent_failures_update_hostdb;
12351237

12361238
params->oride.sock_recv_buffer_size_out = m_master.oride.sock_recv_buffer_size_out;
12371239
params->oride.sock_send_buffer_size_out = m_master.oride.sock_send_buffer_size_out;

proxy/http/HttpConfig.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ struct OverridableHttpConfigParams {
402402
flow_control_enabled(0),
403403
accept_encoding_filter_enabled(0),
404404
normalize_ae_gzip(0),
405+
parent_failures_update_hostdb(0),
405406
negative_caching_lifetime(1800),
406407
negative_revalidating_lifetime(1800),
407408
sock_recv_buffer_size_out(0),
@@ -555,6 +556,11 @@ struct OverridableHttpConfigParams {
555556
////////////////////////////////
556557
MgmtByte normalize_ae_gzip;
557558

559+
//////////////////////////
560+
// hostdb/dns variables //
561+
//////////////////////////
562+
MgmtByte parent_failures_update_hostdb;
563+
558564
////////////////////////////////
559565
// Negative cache lifetimes //
560566
////////////////////////////////

proxy/http/HttpTransact.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3603,7 +3603,11 @@ HttpTransact::handle_response_from_parent(State *s)
36033603
ink_assert(s->hdr_info.server_request.valid());
36043604

36053605
s->current.server->connect_result = ENOTCONN;
3606-
s->state_machine->do_hostdb_update_if_necessary();
3606+
// only mark the parent down in hostdb if the configuration allows it,
3607+
// see proxy.config.http.parent_proxy.mark_down_hostdb in records.config.
3608+
if (s->txn_conf->parent_failures_update_hostdb) {
3609+
s->state_machine->do_hostdb_update_if_necessary();
3610+
}
36073611

36083612
char addrbuf[INET6_ADDRSTRLEN];
36093613
DebugTxn("http_trans", "[%d] failed to connect to parent %s", s->current.attempts,

0 commit comments

Comments
 (0)