[
https://issues.apache.org/jira/browse/TS-4570?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15343145#comment-15343145
]
James Peach commented on TS-4570:
---------------------------------
Note that this subtly alters the ordering of hook callbacks. Normally, DNS is
resolved before {{TS_HTTP_OS_DNS_HOOK}}, but with this change, on connection
retries DNS will be resolved after {{TS_HTTP_OS_DNS_HOOK}}. I think that doing
DNS after the hook makes the most sense, but maybe we should push the
transaction all the way back to post-remap?
Anyway, I wanted to capture what was going on here so we can discuss.
> Return to TS_HTTP_OS_DNS_HOOK after 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)