This is an automated email from the ASF dual-hosted git repository.
jrushford pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 1da1499 Parent Selection -- Make self-detection configurable.
1da1499 is described below
commit 1da149923f4f28c0b382b5299f5cfa5e7ab9bcf1
Author: Peter Chou <[email protected]>
AuthorDate: Tue Apr 24 10:33:14 2018 -0700
Parent Selection -- Make self-detection configurable.
* Adds a new configuration option
"proxy.config.http.parent_proxy.self_detect" that
enables "1" or disables "0" the self detection filtering of parent lists
specified in parent.config. The default is "1".
* The self detect filtering only filters on the host rather than the
host:port so this
filtering can interfere with certain configurations such as test/dev hosts
that have multiple instances of ATS running on different ports.
* Also, modified the string-tokenizer delimiter in PreProcessParents() to
include
";, " rather than just ";" since the ProcessParents() delimiter includes
these characters.
---
doc/admin-guide/files/records.config.en.rst | 5 +++++
mgmt/RecordsConfig.cc | 2 ++
proxy/ParentSelection.cc | 21 ++++++++++++++-------
3 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/doc/admin-guide/files/records.config.en.rst
b/doc/admin-guide/files/records.config.en.rst
index b5f30ea..9ac0102 100644
--- a/doc/admin-guide/files/records.config.en.rst
+++ b/doc/admin-guide/files/records.config.en.rst
@@ -1317,6 +1317,11 @@ Parent Proxy Configuration
.. ts:cv:: CONFIG proxy.local.http.parent_proxy.disable_connect_tunneling INT 0
+.. ts:cv:: CONFIG proxy.config.http.parent_proxy.self_detect INT 1
+
+ Filter out hosts that are determined to be the same as the current host,
e.g., localhost,
+ that have been specified in any parent and secondary_parent lists in the
parent.config file.
+
HTTP Connection Timeouts
========================
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index 7b1fa78..ce159ce 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -446,6 +446,8 @@ static const RecordElement RecordsConfig[] =
,
{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.parent_proxy.self_detect", RECD_INT, "1",
RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, 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/proxy/ParentSelection.cc b/proxy/ParentSelection.cc
index 3ceeab9..86d8de7 100644
--- a/proxy/ParentSelection.cc
+++ b/proxy/ParentSelection.cc
@@ -40,6 +40,7 @@ typedef ControlMatcher<ParentRecord, ParentResult> P_table;
// Global Vars for Parent Selection
static const char modulePrefix[] =
"[ParentSelection]";
static ConfigUpdateHandler<ParentConfig> *parentConfigUpdate = nullptr;
+static int self_detect = 1;
// Config var names
static const char *file_var = "proxy.config.http.parent_proxy.file";
@@ -350,33 +351,34 @@ ParentRecord::PreProcessParents(const char *val, const
int line_num, char *buf,
char *_val = static_cast<char *>(ats_strndup(val,
strlen(val)));
char fqdn[TS_MAX_HOST_NAME_LEN] = {0}, *nm, *token, *savePtr;
std::string str;
- Machine *machine = Machine::instance();
+ Machine *machine = Machine::instance();
+ constexpr char PARENT_DELIMITERS[] = ";, ";
strncpy(_val, val, strlen(val));
- token = strtok_r(_val, ";", &savePtr);
+ token = strtok_r(_val, PARENT_DELIMITERS, &savePtr);
while (token != nullptr) {
if ((nm = strchr(token, ':')) != nullptr) {
size_t len = (nm - token);
ink_assert(len < sizeof(fqdn));
memset(fqdn, 0, sizeof(fqdn));
strncpy(fqdn, token, len);
- if (machine->is_self(fqdn)) {
+ if (self_detect && machine->is_self(fqdn)) {
Debug("parent_select", "token: %s, matches this machine. Removing
self from parent list at line %d", fqdn, line_num);
- token = strtok_r(nullptr, ";", &savePtr);
+ token = strtok_r(nullptr, PARENT_DELIMITERS, &savePtr);
continue;
}
} else {
- if (machine->is_self(token)) {
+ if (self_detect && machine->is_self(token)) {
Debug("parent_select", "token: %s, matches this machine. Removing
self from parent list at line %d", token, line_num);
- token = strtok_r(nullptr, ";", &savePtr);
+ token = strtok_r(nullptr, PARENT_DELIMITERS, &savePtr);
continue;
}
}
str += token;
str += ";";
- token = strtok_r(nullptr, ";", &savePtr);
+ token = strtok_r(nullptr, PARENT_DELIMITERS, &savePtr);
}
strncpy(buf, str.c_str(), len);
ats_free(_val);
@@ -580,10 +582,15 @@ ParentRecord::Init(matcher_line *line_info)
bool used = false;
ParentRR_t round_robin = P_NO_ROUND_ROBIN;
char buf[128];
+ RecInt rec_self_detect = 1;
this->line_num = line_info->line_num;
this->scheme = nullptr;
+ if (RecGetRecordInt("proxy.config.http.parent_proxy.self_detect",
&rec_self_detect) == REC_ERR_OKAY) {
+ self_detect = static_cast<int>(rec_self_detect);
+ }
+
for (int i = 0; i < MATCHER_MAX_TOKENS; i++) {
used = false;
label = line_info->line[0][i];
--
To stop receiving notification emails like this one, please contact
[email protected].