-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
dns: configuring a basic key value store to persist to disk #17745
Changes from 1 commit
7c3e296
ade78e0
253dbae
7104f0f
ca9e396
1c37b93
d2b4fb0
ab188c0
f229567
30eb561
a94bc2a
5dd50d7
51063a8
2810696
7b2b206
e9fd018
a431763
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# DO NOT EDIT. This file is generated by tools/proto_format/proto_sync.py. | ||
|
||
load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package") | ||
|
||
licenses(["notice"]) # Apache 2 | ||
|
||
api_proto_package( | ||
deps = ["@com_github_cncf_udpa//udpa/annotations:pkg"], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
syntax = "proto3"; | ||
|
||
package envoy.extensions.common.key_value.file_based.v3; | ||
|
||
import "google/protobuf/any.proto"; | ||
import "google/protobuf/duration.proto"; | ||
|
||
import "udpa/annotations/status.proto"; | ||
import "validate/validate.proto"; | ||
|
||
option java_package = "io.envoyproxy.envoy.extensions.common.key_value.file_based.v3"; | ||
option java_outer_classname = "ConfigProto"; | ||
option java_multiple_files = true; | ||
option (udpa.annotations.file_status).package_version_status = ACTIVE; | ||
|
||
// [#alpha:] | ||
// [#extension: envoy.common.key_value.file_based] | ||
// This is configuration to flush a key value store out to disk. | ||
message FileBasedKeyValueStoreConfig { | ||
// The filename to read the keys and values from, and write the keys and | ||
// values to. | ||
string filename = 1 [(validate.rules).string = {min_len: 1}]; | ||
|
||
// The interval at which the key value store should be flushed to the file. | ||
google.protobuf.Duration flush_interval = 2; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -442,12 +442,12 @@ void DnsCacheImpl::removeCacheEntry(const std::string& host) { | |
|
||
void DnsCacheImpl::loadCacheEntries( | ||
const envoy::extensions::common::dynamic_forward_proxy::v3::DnsCacheConfig& config) { | ||
if (!config.has_persistent_cache_config()) { | ||
if (!config.has_key_value_config()) { | ||
return; | ||
} | ||
auto& factory = Config::Utility::getAndCheckFactory<KeyValueStoreFactory>( | ||
config.persistent_cache_config().config()); | ||
key_value_store_ = factory.createStore(config.persistent_cache_config(), validation_visitor_, | ||
auto& factory = | ||
Config::Utility::getAndCheckFactory<KeyValueStoreFactory>(config.key_value_config().config()); | ||
key_value_store_ = factory.createStore(config.key_value_config(), validation_visitor_, | ||
main_thread_dispatcher_, file_system_); | ||
KeyValueStore::ConstIterateCb load = [this](const std::string& key, const std::string& value) { | ||
auto address = Network::Utility::parseInternetAddressAndPortNoThrow(value); | ||
|
@@ -456,6 +456,8 @@ void DnsCacheImpl::loadCacheEntries( | |
} | ||
stats_.cache_load_.inc(); | ||
std::list<Network::DnsResponse> response; | ||
// TODO(alyssawilk) change finishResolve to actually use the TTL rather than | ||
// putting 0 here, return the remaining TTL or indicate the result is stale. | ||
response.emplace_back(Network::DnsResponse(address, std::chrono::seconds(0) /* ttl */)); | ||
alyssawilk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
startCacheLoad(key, address->ip()->port()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not that familiar with this code, but it looks like this will kick off a DNS query? And then we immediately resolve it? If so I wonder if this will cause unforeseen consequences, like having entries being resolved twice (once from cache and once from DNS) and confusing stats (e.g. stat increment for DNS resolution and cache load for same entry) Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it works today (see integration test) but I agree it's not great, hence the TODO :-) What I want to have happen is be able to differentiate stale cached results from fresh. I do want to immediately kick off a resolve, but also have stale data in there, config for how long we wait for fresh data before we use stale data. I plan to do that in the follow up There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For my understanding, would a DNS resolution then overwrite this value once it arrives? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, fresh resolve always overwrites older data (if it's different) |
||
finishResolve(key, Network::DnsResolver::ResolutionStatus::Success, std::move(response), true); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this should be in
api/envoy/extensions/key_value/filed_based/v3/config.proto
and same package namespace.The rationale is that the
KeyValueConfig
is a common extension point declaration reused across protos. TheFileBasedKkeyValueStoreConfig
is akey_value
extension, and all extension classes have a root likeapi/envoy/extensions/<extension class>
.