Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion doc/admin-guide/files/parent.config.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ The following list shows the possible actions and their allowed values.
origin server. You can specify either a hostname or an IP address,
but; you must specify the port number.

.. _parent-config-format-secondary_parent-parent:

``secondary_parent``
An optional ordered list of secondary parent servers using the same format
as the ``parent`` list. A ``secondary_parent`` list only applies
when ``round_robin`` is set to ``consistent_hash``. When using
``consistent_hash``, if the server chosen from the primary list fails,
a parent is selected from a secondary consistent hash ring. This feature
works best in a multi-tiered cache hierarchy where one might take advantage
of the content affinint built up on a secondary list of parents.

.. _parent-config-format-round-robin:

``round_robin``
Expand All @@ -145,7 +156,24 @@ The following list shows the possible actions and their allowed values.
would go to the down parent is rehashed amongst the remaining parents.
The other traffic is unaffected. Once the downed parent becomes
available, the traffic distribution returns to the pre-down
state.
state. If a ``secondary_parent`` list is used, the url hashed against
a parent in the ``secondary_parent`` list. Use this to take advantage
of content affinity built up in a secondary group of parents.

.. _parent-config-format-parent_is_proxy:

``parent_is_proxy``
One of the following values:

- ``true`` - Specifies that the parents are ATS cache proxies, within
a hierarchy. This is the default value, if ``parent_is_proxy``
is not specified in the configuration.

- ``false`` - Specifies that the parents are origin servers. The request
url's are modified so they are appropriate for origin
requests. Normal Parent Selection behaviour applies to
the origins listed. Since these would be a list of origin
servers, set go_direct described below to ``false``.

.. _parent-config-format-go-direct:

Expand Down
20 changes: 20 additions & 0 deletions doc/admin-guide/files/records.config.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,26 @@ Parent Proxy Configuration

Don't try to resolve DNS, forward all DNS requests to the parent. This is off (``0``) by default.

.. ts:cv:: CONFIG proxy.config.http.parent_origin.simple_retry_enabled INT 0

Enable the simple retry feature, This is off (``0``) by default. simple retry is only used for
parent origin servers, see configuration information for parent.config.

.. ts:cv:: CONFIG proxy.config.http.parent_origin.simple_retry_response_codes STRING 0

This is a comma separated list of response codes that will trigger a simple retry on a parent
origin server if ``simple_retry`` above is enabled. This is a ``404`` by default.

.. ts:cv:: CONFIG proxy.config.http.parent_origin.dead_server_retry_enabled INT 0

Enable the dead_server retry feature, This is off (``0``) by default. dead server retry
is only used for parent origin servers, see configuration information for parent.config.

.. ts:cv:: CONFIG proxy.config.http.parent_origin.dead_server_retry_response_codes STRING 0

This is a comma separated list of response codes that will trigger a dead server retry on
a parent origin server if ``dead_server_retry`` above is enabled. This is a ``503`` by default.

HTTP Connection Timeouts
========================

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ The following configurations (from ``records.config``) are overridable.
| :ts:cv:`proxy.config.http.cache.range.write`
| :ts:cv:`proxy.config.http.global_user_agent_header`
| :ts:cv:`proxy.config.http.slow.log.threshold`
| :ts:cv:`proxy.config.http.parent_proxy.per_parent_connect_attempts`
| :ts:cv:`proxy.config.http.parent_proxy.total_connect_attempts`
| :ts:cv:`proxy.config.http.parent_origin.simple_retry_enabled`
| :ts:cv:`proxy.config.http.parent_origin.simple_retry_response_codes`
| :ts:cv:`proxy.config.http.parent_origin.dead_server_retry_enabled`
| :ts:cv:`proxy.config.http.parent_origin.dead_server_retry_response_codes`

Examples
========
Expand Down
12 changes: 12 additions & 0 deletions doc/developer-guide/api/types/TSOverridableConfigKey.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,18 @@ Enumeration Members

.. c:member:: TSOverridableConfigKey TS_CONFIG_HTTP_GLOBAL_USER_AGENT_HEADER

.. c:member:: TSOverridableConfigKey TS_CONFIG_HTTP_PER_PARENT_CONNECT_ATTEMPTS

.. c:member:: TSOverridableConfigKey TS_CONFIG_HTTP_PARENT_TOTAL_CONNECT_ATTEMPTS

.. c:member:: TSOverridableConfigKey TS_CONFIG_HTTP_SIMPLE_RETRY_ENABLED

.. c:member:: TSOverridableConfigKey TS_CONFIG_HTTP_SIMPLE_RETRY_RESPONSE_CODES

.. c:member:: TSOverridableConfigKey TS_CONFIG_HTTP_DEAD_SERVER_RETRY_ENABLED

.. c:member:: TSOverridableConfigKey TS_CONFIG_HTTP_DEAD_SERVER_RETRY_RESPONSE_CODES

.. c:member:: TSOverridableConfigKey TS_CONFIG_LAST_ENTRY

Description
Expand Down
50 changes: 45 additions & 5 deletions lib/ts/ConsistentHash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
limitations under the License.
*/

#include "ts/ConsistentHash.h"
#include "ConsistentHash.h"
#include <cstring>
#include <string>
#include <sstream>
Expand Down Expand Up @@ -67,13 +67,19 @@ ATSConsistentHash::insert(ATSConsistentHashNode *node, float weight, ATSHash64 *
}

ATSConsistentHashNode *
ATSConsistentHash::lookup(const char *url, ATSConsistentHashIter *i, bool *w, ATSHash64 *h)
ATSConsistentHash::lookup(const char *url, size_t url_len, ATSConsistentHashIter *i, bool *w, ATSHash64 *h)
{
uint64_t url_hash;
ATSConsistentHashIter NodeMapIterUp, *iter;
ATSHash64 *thash;
bool *wptr, wrapped = false;

if (url_len <= 0 && url) {
url_len = strlen(url);
} else {
url_len = 0;
}

if (h) {
thash = h;
} else if (hash) {
Expand All @@ -95,7 +101,7 @@ ATSConsistentHash::lookup(const char *url, ATSConsistentHashIter *i, bool *w, AT
}

if (url) {
thash->update(url, strlen(url));
thash->update(url, url_len);
thash->final();
url_hash = thash->get();
thash->clear();
Expand Down Expand Up @@ -124,13 +130,19 @@ ATSConsistentHash::lookup(const char *url, ATSConsistentHashIter *i, bool *w, AT
}

ATSConsistentHashNode *
ATSConsistentHash::lookup_available(const char *url, ATSConsistentHashIter *i, bool *w, ATSHash64 *h)
ATSConsistentHash::lookup_available(const char *url, size_t url_len, ATSConsistentHashIter *i, bool *w, ATSHash64 *h)
{
uint64_t url_hash;
ATSConsistentHashIter NodeMapIterUp, *iter;
ATSHash64 *thash;
bool *wptr, wrapped = false;

if (url_len <= 0 && url) {
url_len = strlen(url);
} else {
url_len = 0;
}

if (h) {
thash = h;
} else if (hash) {
Expand All @@ -152,7 +164,7 @@ ATSConsistentHash::lookup_available(const char *url, ATSConsistentHashIter *i, b
}

if (url) {
thash->update(url, strlen(url));
thash->update(url, url_len);
thash->final();
url_hash = thash->get();
thash->clear();
Expand All @@ -179,6 +191,34 @@ ATSConsistentHash::lookup_available(const char *url, ATSConsistentHashIter *i, b
return (*iter)->second;
}

ATSConsistentHashNode *
ATSConsistentHash::lookup_by_hashval(uint64_t hashval, ATSConsistentHashIter *i, bool *w)
{
ATSConsistentHashIter NodeMapIterUp, *iter;
bool *wptr, wrapped = false;

if (w) {
wptr = w;
} else {
wptr = &wrapped;
}

if (i) {
iter = i;
} else {
iter = &NodeMapIterUp;
}

*iter = NodeMap.lower_bound(hashval);

if (*iter == NodeMap.end()) {
*wptr = true;
*iter = NodeMap.begin();
}

return (*iter)->second;
}

ATSConsistentHash::~ATSConsistentHash()
{
if (hash) {
Expand Down
10 changes: 6 additions & 4 deletions lib/ts/ConsistentHash.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#ifndef __CONSISTENT_HASH_H__
#define __CONSISTENT_HASH_H__

#include "ts/Hash.h"
#include "Hash.h"
#include <stdint.h>
#include <iostream>
#include <map>
Expand All @@ -49,9 +49,11 @@ typedef std::map<uint64_t, ATSConsistentHashNode *>::iterator ATSConsistentHashI
struct ATSConsistentHash {
ATSConsistentHash(int r = 1024, ATSHash64 *h = NULL);
void insert(ATSConsistentHashNode *node, float weight = 1.0, ATSHash64 *h = NULL);
ATSConsistentHashNode *lookup(const char *url = NULL, ATSConsistentHashIter *i = NULL, bool *w = NULL, ATSHash64 *h = NULL);
ATSConsistentHashNode *lookup_available(const char *url = NULL, ATSConsistentHashIter *i = NULL, bool *w = NULL,
ATSHash64 *h = NULL);
ATSConsistentHashNode *lookup(const char *url = NULL, size_t url_len = 0, ATSConsistentHashIter *i = NULL, bool *w = NULL,
ATSHash64 *h = NULL);
ATSConsistentHashNode *lookup_available(const char *url = NULL, size_t url_len = 0, ATSConsistentHashIter *i = NULL,
bool *w = NULL, ATSHash64 *h = NULL);
ATSConsistentHashNode *lookup_by_hashval(uint64_t hashval, ATSConsistentHashIter *i = NULL, bool *w = NULL);
~ATSConsistentHash();

private:
Expand Down
6 changes: 6 additions & 0 deletions lib/ts/apidefs.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,12 @@ typedef enum {
TS_CONFIG_HTTP_NUMBER_OF_REDIRECTIONS,
TS_CONFIG_HTTP_CACHE_MAX_OPEN_WRITE_RETRIES,
TS_CONFIG_HTTP_REDIRECT_USE_ORIG_CACHE_KEY,
TS_CONFIG_HTTP_PER_PARENT_CONNECT_ATTEMPTS,
TS_CONFIG_HTTP_PARENT_TOTAL_CONNECT_ATTEMPTS,
TS_CONFIG_HTTP_SIMPLE_RETRY_ENABLED,
TS_CONFIG_HTTP_SIMPLE_RETRY_RESPONSE_CODES,
TS_CONFIG_HTTP_DEAD_SERVER_RETRY_ENABLED,
TS_CONFIG_HTTP_DEAD_SERVER_RETRY_RESPONSE_CODES,
TS_CONFIG_LAST_ENTRY
} TSOverridableConfigKey;

Expand Down
11 changes: 11 additions & 0 deletions mgmt/RecordsConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,17 @@ static const RecordElement RecordsConfig[] =
{RECT_CONFIG, "proxy.config.http.forward.proxy_auth_to_parent", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_NULL, NULL, RECA_NULL}
,

// ###################################
// # parent origin configuration #
// ###################################
{RECT_CONFIG, "proxy.config.http.parent_origin.simple_retry_enabled", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
,
{RECT_CONFIG, "proxy.config.http.parent_origin.simple_retry_response_codes", RECD_STRING, "404", RECU_DYNAMIC, RR_NULL, RECC_STR, "^([0-9]+,)$", RECA_NULL}
,
{RECT_CONFIG, "proxy.config.http.parent_origin.dead_server_retry_enabled", RECD_INT, "0", RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-1]", RECA_NULL}
,
{RECT_CONFIG, "proxy.config.http.parent_origin.dead_server_retry_response_codes", RECD_STRING, "503", RECU_DYNAMIC, RR_NULL, RECC_STR, "^([0-9]+,)$", RECA_NULL}
,
// ###################################
// # NO DNS DOC IN CACHE #
// ###################################
Expand Down
13 changes: 11 additions & 2 deletions plugins/experimental/ts_lua/ts_lua_http_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ typedef enum {
TS_LUA_CONFIG_HTTP_NUMBER_OF_REDIRECTIONS = TS_CONFIG_HTTP_NUMBER_OF_REDIRECTIONS,
TS_LUA_CONFIG_HTTP_CACHE_MAX_OPEN_WRITE_RETRIES = TS_CONFIG_HTTP_CACHE_MAX_OPEN_WRITE_RETRIES,
TS_LUA_CONFIG_HTTP_REDIRECT_USE_ORIG_CACHE_KEY = TS_CONFIG_HTTP_REDIRECT_USE_ORIG_CACHE_KEY,
TS_LUA_CONFIG_HTTP_PER_PARENT_CONNECT_ATTEMPTS = TS_CONFIG_HTTP_PER_PARENT_CONNECT_ATTEMPTS,
TS_LUA_CONFIG_HTTP_PARENT_TOTAL_CONNECT_ATTEMPTS = TS_CONFIG_HTTP_PARENT_TOTAL_CONNECT_ATTEMPTS,
TS_LUA_CONFIG_HTTP_SIMPLE_RETRY_ENABLED = TS_CONFIG_HTTP_SIMPLE_RETRY_ENABLED,
TS_LUA_CONFIG_HTTP_SIMPLE_RETRY_RESPONSE_CODES = TS_CONFIG_HTTP_SIMPLE_RETRY_RESPONSE_CODES,
TS_LUA_CONFIG_HTTP_DEAD_SERVER_RETRY_ENABLED = TS_CONFIG_HTTP_DEAD_SERVER_RETRY_ENABLED,
TS_LUA_CONFIG_HTTP_DEAD_SERVER_RETRY_RESPONSE_CODES = TS_CONFIG_HTTP_SIMPLE_RETRY_RESPONSE_CODES,
TS_LUA_CONFIG_LAST_ENTRY = TS_CONFIG_LAST_ENTRY,
} TSLuaOverridableConfigKey;

Expand Down Expand Up @@ -195,8 +201,11 @@ ts_lua_var_item ts_lua_http_config_vars[] = {
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_CACHE_GENERATION), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_BODY_FACTORY_TEMPLATE_BASE),
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_CACHE_OPEN_WRITE_FAIL_ACTION),
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_ENABLE_REDIRECTION), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_NUMBER_OF_REDIRECTIONS),
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_CACHE_MAX_OPEN_WRITE_RETRIES),
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_REDIRECT_USE_ORIG_CACHE_KEY), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_LAST_ENTRY),
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_CACHE_MAX_OPEN_WRITE_RETRIES), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_REDIRECT_USE_ORIG_CACHE_KEY),
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_PER_PARENT_CONNECT_ATTEMPTS), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_PARENT_TOTAL_CONNECT_ATTEMPTS),
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_SIMPLE_RETRY_ENABLED), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_SIMPLE_RETRY_RESPONSE_CODES),
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_DEAD_SERVER_RETRY_ENABLED), TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_DEAD_SERVER_RETRY_RESPONSE_CODES),
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_LAST_ENTRY),
};

// Needed to make sure we have the latest list of overridable http config vars when compiling
Expand Down
74 changes: 72 additions & 2 deletions proxy/InkAPI.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7980,6 +7980,30 @@ _conf_to_memberp(TSOverridableConfigKey conf, OverridableHttpConfigParams *overr
typ = OVERRIDABLE_TYPE_INT;
ret = &overridableHttpConfig->redirect_use_orig_cache_key;
break;
case TS_CONFIG_HTTP_PER_PARENT_CONNECT_ATTEMPTS:
typ = OVERRIDABLE_TYPE_INT;
ret = &overridableHttpConfig->per_parent_connect_attempts;
break;
case TS_CONFIG_HTTP_PARENT_TOTAL_CONNECT_ATTEMPTS:
typ = OVERRIDABLE_TYPE_INT;
ret = &overridableHttpConfig->parent_connect_attempts;
break;
case TS_CONFIG_HTTP_SIMPLE_RETRY_ENABLED:
typ = OVERRIDABLE_TYPE_INT;
ret = &overridableHttpConfig->simple_retry_enabled;
break;
case TS_CONFIG_HTTP_SIMPLE_RETRY_RESPONSE_CODES:
ret = &overridableHttpConfig->simple_retry_response_codes_string;
typ = OVERRIDABLE_TYPE_STRING;
break;
case TS_CONFIG_HTTP_DEAD_SERVER_RETRY_ENABLED:
typ = OVERRIDABLE_TYPE_INT;
ret = &overridableHttpConfig->dead_server_retry_enabled;
break;
case TS_CONFIG_HTTP_DEAD_SERVER_RETRY_RESPONSE_CODES:
ret = &overridableHttpConfig->dead_server_retry_response_codes_string;
typ = OVERRIDABLE_TYPE_STRING;
break;
// This helps avoiding compiler warnings, yet detect unhandled enum members.
case TS_CONFIG_NULL:
case TS_CONFIG_LAST_ENTRY:
Expand Down Expand Up @@ -8134,6 +8158,20 @@ TSHttpTxnConfigStringSet(TSHttpTxn txnp, TSOverridableConfigKey conf, const char
s->t_state.txn_conf->body_factory_template_base_len = 0;
}
break;
case TS_CONFIG_HTTP_SIMPLE_RETRY_RESPONSE_CODES:
if (value && length > 0) {
s->t_state.txn_conf->simple_retry_response_codes_string = const_cast<char *>(value); // The "core" likes non-const char*
} else {
s->t_state.txn_conf->simple_retry_response_codes_string = NULL;
}
break;
case TS_CONFIG_HTTP_DEAD_SERVER_RETRY_RESPONSE_CODES:
if (value && length > 0) {
s->t_state.txn_conf->dead_server_retry_response_codes_string = const_cast<char *>(value); // The "core" likes non-const char*
} else {
s->t_state.txn_conf->dead_server_retry_response_codes_string = NULL;
}
break;
default:
return TS_ERROR;
break;
Expand Down Expand Up @@ -8587,6 +8625,10 @@ TSHttpTxnConfigFind(const char *name, int length, TSOverridableConfigKey *conf,
if (!strncmp(name, "proxy.config.http.cache.cache_urls_that_look_dynamic", length))
cnf = TS_CONFIG_HTTP_CACHE_CACHE_URLS_THAT_LOOK_DYNAMIC;
break;
case 'd':
if (!strncmp(name, "proxy.config.http.parent_origin.simple_retry_enabled", length))
cnf = TS_CONFIG_HTTP_SIMPLE_RETRY_ENABLED;
break;
case 'n':
if (!strncmp(name, "proxy.config.http.transaction_no_activity_timeout_in", length))
cnf = TS_CONFIG_HTTP_TRANSACTION_NO_ACTIVITY_TIMEOUT_IN;
Expand All @@ -8613,9 +8655,37 @@ TSHttpTxnConfigFind(const char *name, int length, TSOverridableConfigKey *conf,
}
break;

case 57:
if (!strncmp(name, "proxy.config.http.parent_origin.dead_server_retry_enabled", length)) {
cnf = TS_CONFIG_HTTP_DEAD_SERVER_RETRY_ENABLED;
}
break;

case 58:
if (!strncmp(name, "proxy.config.http.connect_attempts_max_retries_dead_server", length))
cnf = TS_CONFIG_HTTP_CONNECT_ATTEMPTS_MAX_RETRIES_DEAD_SERVER;
switch (name[length - 1]) {
case 'r':
if (!strncmp(name, "proxy.config.http.connect_attempts_max_retries_dead_server", length))
cnf = TS_CONFIG_HTTP_CONNECT_ATTEMPTS_MAX_RETRIES_DEAD_SERVER;
break;
case 's':
if (!strncmp(name, "proxy.config.http.parent_proxy.per_parent_connect_attempts", length))
cnf = TS_CONFIG_HTTP_PER_PARENT_CONNECT_ATTEMPTS;
break;
}
break;

case 59:
if (!strncmp(name, "proxy.config.http.parent_origin.simple_retry_response_codes", length)) {
cnf = TS_CONFIG_HTTP_SIMPLE_RETRY_RESPONSE_CODES;
typ = TS_RECORDDATATYPE_STRING;
}
break;

case 64:
if (!strncmp(name, "proxy.config.http.parent_origin.dead_server_retry_response_codes", length)) {
cnf = TS_CONFIG_HTTP_DEAD_SERVER_RETRY_RESPONSE_CODES;
typ = TS_RECORDDATATYPE_STRING;
}
break;
}

Expand Down
Loading