Skip to content
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

config: WatchMap: cleaner management of watches #7108

Merged
merged 40 commits into from
Aug 13, 2019

Conversation

fredlas
Copy link
Contributor

@fredlas fredlas commented May 30, 2019

To be used with delta ADS. Could probably be used with the current GrpcMuxImpl. Has the SubscriptionCallbacks interface, so a GrpcMux can just directly pass onConfigUpdate() calls through to the WatchMap, which will then appropriately distribute the various resources to the various watches' SubscriptionCallbacks. #4991

Risk Level: none, not yet built into Envoy
Testing: unit tests for the new class

Signed-off-by: Fred Douglas <fredlas@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
@fredlas
Copy link
Contributor Author

fredlas commented May 30, 2019

/assign htuch

Signed-off-by: Fred Douglas <fredlas@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
Copy link
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.

Thanks, some design level comments to kick this off.

source/common/config/watch_map.h Outdated Show resolved Hide resolved
source/common/config/watch_map.h Outdated Show resolved Hide resolved
source/common/config/watch_map.h Show resolved Hide resolved
Signed-off-by: Fred Douglas <fredlas@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
source/common/config/watch_map.h Outdated Show resolved Hide resolved
source/common/config/watch_map.h Show resolved Hide resolved
source/common/config/watch_map.h Outdated Show resolved Hide resolved
source/common/config/watch_map.h Show resolved Hide resolved
Signed-off-by: Fred Douglas <fredlas@google.com>
@htuch
Copy link
Member

htuch commented Jul 16, 2019

@fredlas I think it's fine for Watch to be RAII as well as the owning DeltaSubscriptionImpl. RAII is a composable pattern.

@fredlas
Copy link
Contributor Author

fredlas commented Jul 17, 2019

What I'm saying is that the opposite is also true: it is also fine for it not to be RAII. That's relevant here because the RAIIified Watch has led to awkward code/design. If that wasn't the case, then sure, the RAIIness could be wherever. However, I definitely perceive the code to now be worse than it was before.

Copy link
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.

Can you also ensure full coverage in https://249430-65214191-gh.circle-artifacts.com/0/coverage/coverage.source_common_config_watch_map_impl.cc.html?

Other than this, LGTM and we can ship when comments are resolved.
/wait

@fredlas
Copy link
Contributor Author

fredlas commented Jul 22, 2019

@htuch Please review WatchMap in #7293 rather than in here. Once you like how it looks over there, I can copy it back here and merge (just to keep that one smaller). I think it has turned out that the context of how I intend to use WatchMap is actually critical for the review. The version of WatchMap in #7293 is much simpler than here: no interface needed, Watch is a simple struct without functions, and the code is overall easier to follow. That simplicity was lost in here due to Watch becoming a real class, with functionality and RAII. The good design patterns those changes were meant as should be taken care of by how the new DeltaSubscriptionImpl in #7293 makes use of Watch/WatchMap.

@stale
Copy link

stale bot commented Jul 30, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 7 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale stalebot believes this issue/PR has not been touched recently label Jul 30, 2019
@htuch
Copy link
Member

htuch commented Jul 30, 2019

@fredlas yeah, the interface in #7293 is fine, I think this is what we agreed to at our last meeting. This is modulo the move to pushing this under include/envoy; with a pure interface I assume everything under private is now in implementation files rather than the watch_map.h. If you can followup on #7108 (comment) we can merge this. Thanks.

@stale stale bot removed the stale stalebot believes this issue/PR has not been touched recently label Jul 30, 2019
Signed-off-by: Fred Douglas <fredlas@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
Copy link
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.

Interface LGTM, just some tactical implementation comments.
/wait

source/common/config/watch_map.cc Show resolved Hide resolved
source/common/config/watch_map.h Show resolved Hide resolved
source/common/config/watch_map.cc Show resolved Hide resolved
source/common/config/watch_map.cc Show resolved Hide resolved

void WatchMap::removeWatch(Watch* watch) {
wildcard_watches_.erase(watch); // may or may not be in there, but we want it gone.
watches_.erase(watch);
Copy link
Member

Choose a reason for hiding this comment

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

Should we assert it's in at least one of these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd say no; removeWatch is purely for cleanup. Weird as it may be for that to happen, it doesn't mean anything is wrong with the WatchMap.

}

absl::flat_hash_set<Watch*> WatchMap::watchesInterestedIn(const std::string& resource_name) {
// Note that std::set_union needs sorted sets. Better to do it ourselves with insert().
Copy link
Member

Choose a reason for hiding this comment

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

Could we just use an ordered set? std::less gives a total ordering of pointers in C++14.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could, but then updates would be more expensive; watch_interest_ would need to hold ordered sets. Removed that comment; it actually took me a minute to figure out what it was even saying!

test/common/config/watch_map_test.cc Show resolved Hide resolved
Signed-off-by: Fred Douglas <fredlas@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
Signed-off-by: Fred Douglas <fredlas@google.com>
@fredlas
Copy link
Contributor Author

fredlas commented Aug 12, 2019

@htuch ready to go?

Copy link
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.

Great, thanks! Appreciate the patience in getting the design of this clear.

@htuch htuch merged commit 128acb5 into envoyproxy:master Aug 13, 2019
@fredlas
Copy link
Contributor Author

fredlas commented Aug 14, 2019

Hooray, thanks very much!

@rgs1 rgs1 mentioned this pull request Aug 14, 2019
@fredlas fredlas mentioned this pull request Sep 26, 2019
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.

2 participants