Skip to content

dns: removing exceptions from resolver#34409

Merged
alyssawilk merged 3 commits intoenvoyproxy:mainfrom
alyssawilk:dns
Jun 3, 2024
Merged

dns: removing exceptions from resolver#34409
alyssawilk merged 3 commits intoenvoyproxy:mainfrom
alyssawilk:dns

Conversation

@alyssawilk
Copy link
Copy Markdown
Contributor

@alyssawilk alyssawilk commented May 29, 2024

Risk Level: low
Testing: updated tests
Docs Changes: n/a
Release Notes: n/a
envoyproxy/envoy-mobile#176

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

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #34409 was opened by alyssawilk.

see: more, trace.

@alyssawilk alyssawilk marked this pull request as ready for review May 29, 2024 17:40
@jmarantz
Copy link
Copy Markdown
Contributor

Yanjun -- can you do a first pass? After your lgtm I'll assign a maintainer.

const envoy::extensions::network::dns_resolver::cares::v3::CaresDnsResolverConfig& config,
Event::Dispatcher& dispatcher,
const std::vector<Network::Address::InstanceConstSharedPtr>& resolvers,
Event::Dispatcher& dispatcher, absl::optional<std::string> resolvers_csv,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just curious what's the motivation for this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

envoyproxy/envoy-mobile#176 :-)

but more relevant to Envoy, there's also #27412

}
}
return std::make_shared<Network::DnsResolverImpl>(cares, dispatcher, resolvers,
auto csv_or_error = DnsResolverImpl::maybeBuildResolversCsv(resolvers);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks to me there are some logic change here. Previously, if resolvers is empty, the code still go ahead create DnsResolverImpl:

.

Now we skipped it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think so
we only fail if we have an error status. in the case of empty list, we still return absl::nullopt ("no resolvers") not absl::InvalidArgumentError ("failure creating configured resolvers")

Copy link
Copy Markdown
Contributor

@yanjunxiang-google yanjunxiang-google May 30, 2024

Choose a reason for hiding this comment

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

I see. That static function DnsResolverImpl::maybeBuildResolversCsv() never returns Error currently.

But, it throw exceptions here:

Should we change this throw into a return error?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah I had set up to remove it and not yet removed it. Happy to do so (fingers crossed on unit tests, else I'll pick back up monday)

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
return absl::InvalidArgumentError("Redis cluster can only created with redis cluster type.");
}
auto resolver =
THROW_OR_RETURN_VALUE(selectDnsResolver(cluster, context), Network::DnsResolverSharedPtr);
Copy link
Copy Markdown
Contributor

@yanjunxiang-google yanjunxiang-google May 31, 2024

Choose a reason for hiding this comment

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

nit: can we use THROW_IF_NOT_OK() here to be consistent with logical/strict cluster? It's up to you.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think THROW_IF_NOT_OK is significantly more readable than THROW_OR_RETURN_VALUE, too (i.e. consistency is nice, and my preference is for consistency to be achieved in that direction.)

@yanjunxiang-google
Copy link
Copy Markdown
Contributor

LGTM modulo CI error.

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

@yanjunxiang-google yanjunxiang-google left a comment

Choose a reason for hiding this comment

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

LGTM

@jmarantz jmarantz assigned zuercher and ravenblackx and unassigned zuercher May 31, 2024
@jmarantz
Copy link
Copy Markdown
Contributor

@ravenblackx for non-google review (just realized I don't need a senior maintainer since Alyssa is).

@alyssawilk
Copy link
Copy Markdown
Contributor Author

yeah I prefer THROW_OR_SET_VALUE to
foo_or_error = function
THROW_IF_STATUS_NOT_OK(foo_or_error.status()
foo = foo_or_error.value()
so I tend to use it when there's setters involved.

@alyssawilk alyssawilk merged commit 005f119 into envoyproxy:main Jun 3, 2024
mattklein123 pushed a commit that referenced this pull request Dec 11, 2024
<!--
!!!ATTENTION!!!

If you are fixing *any* crash or *any* potential security issue, *do
not*
open a pull request in this repo. Please report the issue via emailing
envoy-security@googlegroups.com where the issue will be triaged
appropriately.
Thank you in advance for helping to keep Envoy secure.

!!!ATTENTION!!!

For an explanation of how to fill out the fields, please see the
relevant section
in
[PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/main/PULL_REQUESTS.md)
-->


Commit Message: 
Additional Description: I believe it is stable now since we conduct a
security review and improvement for dns filter like #18651 #20744 #22861
#17479 #34409 #34456 #34490 and so on
Risk Level: low
Testing:
Docs Changes:
Release Notes:

Signed-off-by: Boteng Yao <boteng@google.com>
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.

5 participants