James Peach created TS-4570:
-------------------------------
Summary: Return to TS_HTTP_OS_DNS_HOOK with explicit DNS
Key: TS-4570
URL: https://issues.apache.org/jira/browse/TS-4570
Project: Traffic Server
Issue Type: Improvement
Components: Core, TS API
Reporter: James Peach
Consider the case of a plugin that has out -of-band routing knowledge
equivalent to DNS. So for a domain, it might have a number of possible IP
addresses. Remap plugins can implement {{TSRemapOSResponse}}, which is called
in the connection result handling path, but there's no facility for global
plugins to reroute the request.
In my case, I'm largely doing forward proxying, so I don't have a remap rule
for everything I need to route. Hence I'm a global plugin.
Here is a relatively hacky patch that backs the state machine back up to
{{TS_HTTP_OS_DNS_HOOK}} if we get a connection failure, have retries left, and
a plugin has called {{TSHttpTxnServerAddrSet}}.
{code}
$ git diff proxy/http/HttpTransact.cc
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index 5ef0430..3363af1 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -3762,6 +3762,11 @@ HttpTransact::handle_response_from_server(State *s)
// families - that is locked in by the client source address.
s->state_machine->ua_session->set_host_res_style(ats_host_res_match(&s->current.server->dst_addr.sa));
TRANSACT_RETURN(SM_ACTION_DNS_LOOKUP, OSDNSLookup);
+ } else if (s->api_server_addr_set) {
+ // If the address was set by a plugin, give it another chance.
+ s->dns_info.os_addr_style = DNSLookupInfo::OS_ADDR_TRY_HOSTDB;
+ s->current.attempts++;
+ TRANSACT_RETURN(SM_ACTION_API_OS_DNS, OSDNSLookup);
} else if ((s->dns_info.srv_lookup_success ||
s->host_db_info.is_rr_elt()) &&
(s->txn_conf->connect_attempts_rr_retries > 0) &&
(s->current.attempts %
s->txn_conf->connect_attempts_rr_retries == 0)) {
{code}
Note that some plugins might be unprepared for {{TS_HTTP_OS_DNS_HOOK}} to be
called multiple times, so we should document that.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)