Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(http_proxy): actually perform DNS resolution when entry is stale #5139

Merged
merged 2 commits into from
Jun 4, 2024
Merged
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
18 changes: 17 additions & 1 deletion ydb/library/actors/http/http_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class THttpProxy : public NActors::TActorBootstrapped<THttpProxy>, public THttpC
void Handle(TEvHttpProxy::TEvResolveHostRequest::TPtr event, const NActors::TActorContext& ctx) {
const TString& host(event->Get()->Host);
auto it = Hosts.find(host);
if (it == Hosts.end() || it->second.DeadlineTime > ctx.Now()) {
if (it == Hosts.end() || it->second.DeadlineTime < ctx.Now()) {
TString addressPart;
TIpPort portPart = 0;
CrackAddress(host, addressPart, portPart);
Expand Down Expand Up @@ -174,6 +174,22 @@ class THttpProxy : public NActors::TActorBootstrapped<THttpProxy>, public THttpC
it->second.DeadlineTime = ctx.Now() + HostsTimeToLive;
}
}
catch (const TNetworkResolutionError& e) {
if (it != Hosts.end()) {
ctx.Send(event->Sender, new TEvHttpProxy::TEvResolveHostResponse(it->first, it->second.Address));
return;
} else {
ctx.Send(event->Sender,
new TEvHttpProxy::TEvResolveHostResponse(
TStringBuilder()
<< "Resolution failed and no stale cached value has been found to fallback.\n"
<< "Resolution error: "
<< e.what()
)
);
return;
}
}
catch (const yexception& e) {
ctx.Send(event->Sender, new TEvHttpProxy::TEvResolveHostResponse(e.what()));
return;
Expand Down
Loading