Skip to content

config: add path_config_source and watched_directory config#19974

Merged
mattklein123 merged 6 commits intomainfrom
path_xds
Feb 17, 2022
Merged

config: add path_config_source and watched_directory config#19974
mattklein123 merged 6 commits intomainfrom
path_xds

Conversation

@mattklein123
Copy link
Copy Markdown
Member

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

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>
@repokitteh-read-only
Copy link
Copy Markdown

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: #19974 was opened by mattklein123.

see: more, trace.

Signed-off-by: Matt Klein <mklein@lyft.com>
Signed-off-by: Matt Klein <mklein@lyft.com>
Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

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) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you map the legacy case to WatchedDirectory to dedupe this logic?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

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.

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).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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: {}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

@snowp snowp left a comment

Choose a reason for hiding this comment

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

Thanks, just one small suggestion

Signed-off-by: Matt Klein <mklein@lyft.com>
Copy link
Copy Markdown
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.

API LGTM, modulo comment from @htuch.

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) {
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.

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).

Signed-off-by: Matt Klein <mklein@lyft.com>
Signed-off-by: Matt Klein <mklein@lyft.com>
@mattklein123
Copy link
Copy Markdown
Member Author

/retest

@repokitteh-read-only
Copy link
Copy Markdown

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #19974 (comment) was created by @mattklein123.

see: more, trace.

Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

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"};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Probably not worth it for these marginal deprecated paths, so let's skip.

Copy link
Copy Markdown
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
LGTM code changes.

@mattklein123 mattklein123 merged commit 8670309 into main Feb 17, 2022
@mattklein123 mattklein123 deleted the path_xds branch February 17, 2022 15:50
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.

Improve SDS file watching docs

4 participants