config: add path_config_source and watched_directory config#19974
config: add path_config_source and watched_directory config#19974mattklein123 merged 6 commits intomainfrom
Conversation
For xDS over the file system, sometimes more control is required over what directory/file is watched for symbolic link swaps. Specifically, in order to deliver xDS over a Kubernetes ConfigMap, this extra configuration is required. Fixes #10979 Signed-off-by: Matt Klein <mklein@lyft.com>
|
CC @envoyproxy/api-shepherds: Your approval is needed for changes made to |
Signed-off-by: Matt Klein <mklein@lyft.com>
htuch
left a comment
There was a problem hiding this comment.
API/implementation LGTM modulo minor comments, will look at tests tomorow.
| stats_(stats), api_(api), validation_visitor_(validation_visitor) { | ||
| if (!path_config_source.has_watched_directory()) { | ||
| file_watcher_ = dispatcher.createFilesystemWatcher(); | ||
| file_watcher_->addWatch(path_, Filesystem::Watcher::Events::MovedTo, [this](uint32_t) { |
There was a problem hiding this comment.
Can you map the legacy case to WatchedDirectory to dedupe this logic?
There was a problem hiding this comment.
I thought about this but I'm not sure how to do this without duplicating a bunch of code that lives inside the watcher (watching a specific file, etc.). Do you have any suggestions? Happy to collapse if there is a good way. FWIW the SDS code has similar bifurcation.
There was a problem hiding this comment.
Not sure if it's worth the hassle, but I think the callback can be refactored, so it's created before the if statement and moved to the file/directory watcher (will also require adding a setCallback(uint32_t) to WatchedDirectory and some refactoring there).
There was a problem hiding this comment.
Yeah, I tried to do this, but rolled it back when I encountered said refactoring. Let's see what @htuch has in mind and then I'm happy to make some changes if it's worthwhile (I'm not sure it is).
There was a problem hiding this comment.
Probably not worth it for these marginal deprecated paths, so let's skip.
| typed_config: | ||
| "@type": type.googleapis.com/envoy.config.metrics.v3.StatsdSink | ||
| tcp_cluster_name: statsd | ||
| watchdog: {} |
There was a problem hiding this comment.
This change and the other one like it are unrelated to this change, however when I built with disabling deprecations locally, the hot restart tests failed (we don't compile hot restart in the CI build which tests this), so I just fixed this at the same time. The empty deprecated watchdog config seems a historical legacy and not relevant to hot restart.
snowp
left a comment
There was a problem hiding this comment.
Thanks, just one small suggestion
Signed-off-by: Matt Klein <mklein@lyft.com>
| stats_(stats), api_(api), validation_visitor_(validation_visitor) { | ||
| if (!path_config_source.has_watched_directory()) { | ||
| file_watcher_ = dispatcher.createFilesystemWatcher(); | ||
| file_watcher_->addWatch(path_, Filesystem::Watcher::Events::MovedTo, [this](uint32_t) { |
There was a problem hiding this comment.
Not sure if it's worth the hassle, but I think the callback can be refactored, so it's created before the if statement and moved to the file/directory watcher (will also require adding a setCallback(uint32_t) to WatchedDirectory and some refactoring there).
|
/retest |
|
Retrying Azure Pipelines: |
| TEST_P(RtdsIntegrationTest, FileRtdsReload) { | ||
| // Create an initial setup that looks similar to a K8s ConfigMap deployment. This is a file | ||
| // contained in a directory and referenced via an intermediate symlink on the directory. | ||
| const std::string temp_path{TestEnvironment::temporaryDirectory() + "/rtds_test"}; |
There was a problem hiding this comment.
Nit: we have temporaryPath() for this.
| stats_(stats), api_(api), validation_visitor_(validation_visitor) { | ||
| if (!path_config_source.has_watched_directory()) { | ||
| file_watcher_ = dispatcher.createFilesystemWatcher(); | ||
| file_watcher_->addWatch(path_, Filesystem::Watcher::Events::MovedTo, [this](uint32_t) { |
There was a problem hiding this comment.
Probably not worth it for these marginal deprecated paths, so let's skip.
adisuissa
left a comment
There was a problem hiding this comment.
/lgtm api
LGTM code changes.
For xDS over the file system, sometimes more control is required over
what directory/file is watched for symbolic link swaps. Specifically,
in order to deliver xDS over a Kubernetes ConfigMap, this extra
configuration is required.
Fixes #10979
Risk Level: Low, new feature
Testing: Integration test
Docs Changes: Added
Release Notes: Added
Platform Specific Features: N/A
Deprecated: Yes, details added