Skip to content

DNS: officially (previously only unofficially) allowing null resolutions#19588

Merged
alyssawilk merged 6 commits intoenvoyproxy:mainfrom
alyssawilk:dns2
Jan 24, 2022
Merged

DNS: officially (previously only unofficially) allowing null resolutions#19588
alyssawilk merged 6 commits intoenvoyproxy:mainfrom
alyssawilk:dns2

Conversation

@alyssawilk
Copy link
Contributor

in #17645 there was a bunch of discussion around the DNS cache returning null addresses and how to handle it. After discussion on #19461 we agreed to keep sending null updates, but to fast-fail if no address was resolved.

Risk Level: Medium (data plane change)
Testing: updated integration tests, unit tests
Docs Changes: n/a
Release Notes: inline

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk
Copy link
Contributor Author

As this is extension code I'm inclined to with you two signing off but if you want a senior maintainer pass LMK.

Copy link
Contributor

@RyanTheOptimist RyanTheOptimist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me, other than a question about a comment that I don't quite grok.

void ProxyFilter::addHostAddressToFilterState(
const Network::Address::InstanceConstSharedPtr& address) {
void ProxyFilter::addHostAddressToFilterState(const Network::Address::InstanceConstSharedPtr& address) {
ASSERT(address); // null pointer checks must be done before calling this function.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was confused for a minute about how a "const T&" could even be null.... then I realized that T is "SharedPtr". Carry on! facepalm

if (!host_info->address()) {
// Generally in Envoy it is not Ok to send a local reply at 2 code points with the same
// details, but here we could leak prior queries if we differentiate new failures from
// cached failures, so intentionally reuse the details.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could chat offline, but I'm not sure that I really understand. Is this comment observing that in ProxyFilter::decodeHeaders() we send the same details that we're sending here? And normally that would be verboten. But if we returned a new error code here, we'd leak to the caller that a previous resolution had failed? Is that a privacy leak or some such?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I was worried this is more confusing than it's worth. Looking at our TODOs I think I also want to add a response flag, then refactored, so I think I can just remove this comment.

largely when we sendLocalReply we're supposed to be able to use rc-details to track exactly what went wrong. generally I'd want separate codes for synchronous-dns-fail and async-dns-fail but that leaks prior requests so I'm intentionally not doing it. I don't think anyone else would realize the quandry so removing for clarity :-P

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM!

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @adisuissa
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #19588 was synchronize by alyssawilk.

see: more, trace.

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Copy link
Contributor

@adisuissa adisuissa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm api
Minor comment on the code, but otherwise LGTM.

if (host.has_value()) {
if (!host.value()->address()) {
onDnsResolutionFail();
return Http::FilterHeadersStatus::StopIteration;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider calling latchTime(decoder_callbacks_, DNS_END); before this line (or in onDnsResolutionFail().

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
adisuissa
adisuissa previously approved these changes Jan 20, 2022
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>

void ProxyFilter::onDnsResolutionFail() {
decoder_callbacks_->streamInfo().setResponseFlag(StreamInfo::ResponseFlag::DnsResolutionFailed);
decoder_callbacks_->sendLocalReply(Http::Code::ServiceUnavailable,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Augustyniak @buildbreaker @goaway @jpsim @Reflejo FYI, now we will have a more explicit error for DNS failures from the forward proxy filter. Rather than the upstream failure error we have gotten used to.

@alyssawilk alyssawilk merged commit 2efe480 into envoyproxy:main Jan 24, 2022
joshperry pushed a commit to joshperry/envoy that referenced this pull request Feb 13, 2022
…ons (envoyproxy#19588)

in envoyproxy#17645 there was a bunch of discussion around the DNS cache returning null addresses and how to handle it. After discussion on envoyproxy#19461 we agreed to keep sending null updates, but to fast-fail if no address was resolved.

Risk Level: Medium (data plane change)
Testing: updated integration tests, unit tests
Docs Changes: n/a
Release Notes: inline

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: Josh Perry <josh.perry@mx.com>
@alyssawilk alyssawilk deleted the dns2 branch August 4, 2022 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants