You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jr...@apache.org on 2016/03/16 16:57:39 UTC
trafficserver git commit: TS-4115: Add a multi origin hierarchy to
parent selection.
Repository: trafficserver
Updated Branches:
refs/heads/master edf9ff13d -> 824f2ab7b
TS-4115: Add a multi origin hierarchy to parent selection.
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/824f2ab7
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/824f2ab7
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/824f2ab7
Branch: refs/heads/master
Commit: 824f2ab7bde25b9b7f8da48fdf36bc3278920444
Parents: edf9ff1
Author: John J. Rushford <Jo...@cable.comcast.com>
Authored: Tue Feb 23 20:59:49 2016 +0000
Committer: John J. Rushford <Jo...@cable.comcast.com>
Committed: Wed Mar 16 15:15:30 2016 +0000
----------------------------------------------------------------------
doc/admin-guide/files/parent.config.en.rst | 12 +++++++++++
proxy/ParentConsistentHash.cc | 4 ++--
proxy/ParentRoundRobin.cc | 6 +++---
proxy/ParentSelection.cc | 11 ++++++++++
proxy/ParentSelection.h | 7 ++++---
proxy/http/HttpTransact.cc | 28 ++++++++++++++++---------
6 files changed, 50 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/824f2ab7/doc/admin-guide/files/parent.config.en.rst
----------------------------------------------------------------------
diff --git a/doc/admin-guide/files/parent.config.en.rst b/doc/admin-guide/files/parent.config.en.rst
index e3d8952..a8554f8 100644
--- a/doc/admin-guide/files/parent.config.en.rst
+++ b/doc/admin-guide/files/parent.config.en.rst
@@ -138,6 +138,18 @@ The following list shows the possible actions and their allowed values.
list, then the request will be re-tried from a server found in this list
using a consistent hash of the url.
+.. _parent-config-format-parent-is-proxy:
+
+``parent_is_proxy``
+ One of the following values:
+
+ - ``true`` - This is the default. The list of parents and secondary parents
+ are proxy cache servers.
+ - ``false`` - The list of parents and secondary parents are the origin
+ servers ``go_direct`` flag is ignored and origins are selected using
+ the specified ``round_robin`` algorithm. The FQDN is removed from
+ the http request line.
+
.. _parent-config-format-round-robin:
``round_robin``
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/824f2ab7/proxy/ParentConsistentHash.cc
----------------------------------------------------------------------
diff --git a/proxy/ParentConsistentHash.cc b/proxy/ParentConsistentHash.cc
index 6233bdc..67318bd 100644
--- a/proxy/ParentConsistentHash.cc
+++ b/proxy/ParentConsistentHash.cc
@@ -105,7 +105,7 @@ ParentConsistentHash::selectParent(const ParentSelectionPolicy *policy, bool fir
// Should only get into this state if we are supposed to go direct.
if (parents[PRIMARY] == NULL && parents[SECONDARY] == NULL) {
- if (result->rec->go_direct == true) {
+ if (result->rec->go_direct == true && result->rec->parent_is_proxy == true) {
result->r = PARENT_DIRECT;
} else {
result->r = PARENT_FAIL;
@@ -207,7 +207,7 @@ ParentConsistentHash::selectParent(const ParentSelectionPolicy *policy, bool fir
ink_assert(result->port != 0);
Debug("parent_select", "Chosen parent: %s.%d", result->hostname, result->port);
} else {
- if (result->rec->go_direct == true) {
+ if (result->rec->go_direct == true && result->rec->parent_is_proxy == true) {
result->r = PARENT_DIRECT;
} else {
result->r = PARENT_FAIL;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/824f2ab7/proxy/ParentRoundRobin.cc
----------------------------------------------------------------------
diff --git a/proxy/ParentRoundRobin.cc b/proxy/ParentRoundRobin.cc
index d2a77d0..ac453d3 100644
--- a/proxy/ParentRoundRobin.cc
+++ b/proxy/ParentRoundRobin.cc
@@ -68,7 +68,7 @@ ParentRoundRobin::selectParent(const ParentSelectionPolicy *policy, bool first_c
// if we are supposed to go direct
ink_assert(result->rec->go_direct == true);
// Could not find a parent
- if (result->rec->go_direct == true) {
+ if (result->rec->go_direct == true && result->rec->parent_is_proxy == true) {
result->r = PARENT_DIRECT;
} else {
result->r = PARENT_FAIL;
@@ -111,7 +111,7 @@ ParentRoundRobin::selectParent(const ParentSelectionPolicy *policy, bool first_c
// We've wrapped around so bypass if we can
if (bypass_ok == true) {
// Could not find a parent
- if (result->rec->go_direct == true) {
+ if (result->rec->go_direct == true && result->rec->parent_is_proxy == true) {
result->r = PARENT_DIRECT;
} else {
result->r = PARENT_FAIL;
@@ -166,7 +166,7 @@ ParentRoundRobin::selectParent(const ParentSelectionPolicy *policy, bool first_c
cur_index = (cur_index + 1) % result->rec->num_parents;
} while ((unsigned int)cur_index != result->start_parent);
- if (result->rec->go_direct == true) {
+ if (result->rec->go_direct == true && result->rec->parent_is_proxy == true) {
result->r = PARENT_DIRECT;
} else {
result->r = PARENT_FAIL;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/824f2ab7/proxy/ParentSelection.cc
----------------------------------------------------------------------
diff --git a/proxy/ParentSelection.cc b/proxy/ParentSelection.cc
index f4e9ebb..d4096eb 100644
--- a/proxy/ParentSelection.cc
+++ b/proxy/ParentSelection.cc
@@ -478,6 +478,7 @@ ParentRecord::DefaultInit(char *val)
this->go_direct = true;
this->ignore_query = false;
this->scheme = NULL;
+ this->parent_is_proxy = true;
errPtr = ProcessParents(val, true);
if (errPtr != NULL) {
@@ -560,6 +561,15 @@ ParentRecord::Init(matcher_line *line_info)
this->ignore_query = false;
}
used = true;
+ } else if (strcasecmp(label, "parent_is_proxy") == 0) {
+ if (strcasecmp(val, "false") == 0) {
+ parent_is_proxy = false;
+ } else if (strcasecmp(val, "true") != 0) {
+ errPtr = "invalid argument to parent_is_proxy directed";
+ } else {
+ parent_is_proxy = true;
+ }
+ used = true;
}
// Report errors generated by ProcessParents();
if (errPtr != NULL) {
@@ -647,6 +657,7 @@ ParentRecord::Print()
printf(" %s:%d ", parents[i].hostname, parents[i].port);
}
printf(" direct=%s\n", (go_direct == true) ? "true" : "false");
+ printf(" parent_is_proxy=%s\n", (parent_is_proxy == true) ? "true" : "false");
}
// ParentRecord* createDefaultParent(char* val)
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/824f2ab7/proxy/ParentSelection.h
----------------------------------------------------------------------
diff --git a/proxy/ParentSelection.h b/proxy/ParentSelection.h
index 33adc0a..af0ea8e 100644
--- a/proxy/ParentSelection.h
+++ b/proxy/ParentSelection.h
@@ -90,7 +90,7 @@ class ParentRecord : public ControlBase
public:
ParentRecord()
: parents(NULL), secondary_parents(NULL), num_parents(0), num_secondary_parents(0), ignore_query(false), rr_next(0),
- go_direct(true), selection_strategy(NULL)
+ go_direct(true), parent_is_proxy(true), selection_strategy(NULL)
{
}
@@ -117,6 +117,7 @@ public:
bool ignore_query;
volatile uint32_t rr_next;
bool go_direct;
+ bool parent_is_proxy;
ParentSelectionStrategy *selection_strategy;
};
@@ -163,13 +164,13 @@ struct ParentSelectionPolicy {
class ParentSelectionStrategy
{
public:
- // void selectParent(const ParentSelectionPolicy, *policy, bool firstCall, ParentResult *result, RequestData *rdata)
+ // void selectParent(const ParentSelectionPolicy *policy, bool firstCall, ParentResult *result, RequestData *rdata)
//
// The implementation parent lookup.
//
virtual void selectParent(const ParentSelectionPolicy *policy, bool firstCall, ParentResult *result, RequestData *rdata) = 0;
- // void markParentDown(const ParentSelectionPolicy, *policy, ParentResult* rsult)
+ // void markParentDown(const ParentSelectionPolicy *policy, ParentResult *result)
//
// Marks the parent pointed to by result as down
//
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/824f2ab7/proxy/http/HttpTransact.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index 362c63b..55654d6 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -210,11 +210,12 @@ find_server_and_update_current_info(HttpTransact::State *s)
// I just wanted to do this for cop heartbeats, someone else
// wanted it for all requests to local_host.
s->parent_result.r = PARENT_DIRECT;
- } else if (s->method == HTTP_WKSIDX_CONNECT && s->http_config_param->disable_ssl_parenting) {
+ } else if (s->method == HTTP_WKSIDX_CONNECT && s->http_config_param->disable_ssl_parenting &&
+ s->parent_result.rec->parent_is_proxy) {
s->parent_result.r = PARENT_DIRECT;
} else if (s->http_config_param->uncacheable_requests_bypass_parent && s->http_config_param->no_dns_forward_to_parent == 0 &&
- !HttpTransact::is_request_cache_lookupable(s)) {
- // request not lookupable and cacheable, so bypass parent
+ !HttpTransact::is_request_cache_lookupable(s) && s->parent_result.rec->parent_is_proxy) {
+ // request not lookupable and cacheable, so bypass parent if the parent is not an origin server.
// Note that the configuration of the proxy as well as the request
// itself affects the result of is_request_cache_lookupable();
// we are assuming both child and parent have similar configuration
@@ -246,7 +247,7 @@ find_server_and_update_current_info(HttpTransact::State *s)
// 2) the config permits us
// 3) the config permitted us to dns the origin server
if (!s->parent_params->apiParentExists(&s->request_data) && s->parent_result.rec->bypass_ok() &&
- s->http_config_param->no_dns_forward_to_parent == 0) {
+ s->http_config_param->no_dns_forward_to_parent == 0 && s->parent_result.rec->parent_is_proxy) {
s->parent_result.r = PARENT_DIRECT;
}
break;
@@ -7784,12 +7785,19 @@ HttpTransact::build_request(State *s, HTTPHdr *base_request, HTTPHdr *outgoing_r
// If we're going to a parent proxy, make sure we pass host and port
// in the URL even if we didn't get them (e.g. transparent proxy)
- if (s->current.request_to == PARENT_PROXY && !outgoing_request->is_target_in_url()) {
- DebugTxn("http_trans", "[build_request] adding target to URL for parent proxy");
-
- // No worry about HTTP/0.9 because we reject forward proxy requests that
- // don't have a host anywhere.
- outgoing_request->set_url_target_from_host_field();
+ if (s->current.request_to == PARENT_PROXY) {
+ if (!outgoing_request->is_target_in_url() && s->parent_result.rec->parent_is_proxy) {
+ DebugTxn("http_trans", "[build_request] adding target to URL for parent proxy");
+
+ // No worry about HTTP/0.9 because we reject forward proxy requests that
+ // don't have a host anywhere.
+ outgoing_request->set_url_target_from_host_field();
+ } else if (s->current.request_to == PARENT_PROXY && !s->parent_result.rec->parent_is_proxy &&
+ outgoing_request->is_target_in_url()) {
+ // If the parent is an origin server remove the hostname from the url.
+ DebugTxn("http_trans", "[build_request] removing target from URL for a parent origin.");
+ HttpTransactHeaders::remove_host_name_from_url(outgoing_request);
+ }
}
// If the response is most likely not cacheable, eg, request with Authorization,