Conversation
Signed-off-by: Constance Caramanolis <ccaramanolis@lyft.com>
Signed-off-by: Constance Caramanolis <ccaramanolis@lyft.com>
jmarantz
left a comment
There was a problem hiding this comment.
drive-by comment really to help me learn what the style is supposed to be :)
| * @return tag from the CIDR range that contains 'ip_address'. An empty string is returned | ||
| * if no prefix contains 'ip_address' or there is no data for the IP version of the | ||
| * ip_address. | ||
| * @return a vector of tags from the CIDR ranges and IP addresses that contains 'ip_address'. An |
There was a problem hiding this comment.
There was a problem hiding this comment.
This is a good question. I don't know what peoples preferences are these days. I'll find out.
There was a problem hiding this comment.
In our local chatter, no one understands why we are repeating the types in the comments; and I learned they are not needed for any scripts that generate API doc currently.
IMO your form is better and we should convert everything to it.
There was a problem hiding this comment.
This has come up a couple times. Matt commented that he started the policy out of habit, because some script (super old doxygen from 1973??) output better docs if it was included.
I think we should remove those types from all the docs. They're not providing any value, and they can get out-of-date from the actual types on the function.
If not, we should make a linter that enforces them.
There was a problem hiding this comment.
Agreed, i'll keep it as is.
There was a problem hiding this comment.
Possibly worth a call-out on envoy-dev or maintainers - I'm so happy to kill off that rule, and hadn't realized it was "outdated" so was enforcing.
|
Assigned @junr03 for first maintainer pass since he reviewed the previous LC-Trie PR. @brian-pane Can you also do a review of this here, since I see you are working with this as well? Thanks |
|
This change looks good to me. The one change I can think of would be to replace the std::vector return type with something like Folly's small_vector or Abseil's inlined_vector that doesn't need a heap allocation for the common case where the number of returned tags is small. But those have a drawback: the maximum expected vector size is encoded as a template parameter, and that's a detail that probably shouldn't be exposed in the trie's API. |
|
It looks like the TSAN test failure is due to the (unrelated) bug that was fixed by #2613, so merging master should fix it. |
Signed-off-by: Constance Caramanolis <ccaramanolis@lyft.com>
|
@brian-pane 1. I'm going to leave it as is with std::vector<> I don't want to modify the template parameter. When benchmark testing is added for LC-Trie, we can see if there are any issues with vector. 2. merged master |
alyssawilk
left a comment
There was a problem hiding this comment.
Thanks for splitting the refactor out from the upcoming improvements - It's nice and clean and soo much easier to review!
LGTM overall, just a few nits
| * @return tag from the CIDR range that contains 'ip_address'. An empty string is returned | ||
| * if no prefix contains 'ip_address' or there is no data for the IP version of the | ||
| * ip_address. | ||
| * @return a vector of tags from the CIDR ranges and IP addresses that contains 'ip_address'. An |
There was a problem hiding this comment.
Possibly worth a call-out on envoy-dev or maintainers - I'm so happy to kill off that rule, and hadn't realized it was "outdated" so was enforcing.
source/common/network/lc_trie.h
Outdated
| if (ip_prefixes_[address].length_ == 0) { | ||
| return ip_prefixes_[address].tag_; | ||
| return_vector.push_back(ip_prefixes_[address].tag_); | ||
| // TODO(ccaraman): When nested prefixes are supported, should the /0 case be handled better. |
There was a problem hiding this comment.
super nitty nit - either swap . for ? or make it a statement please
There was a problem hiding this comment.
:) - I'll change it to a '?'.
test/common/network/lc_trie_test.cc
Outdated
|
|
||
| void expectIPAndNoTag(const std::vector<std::string>& test_output) { | ||
| for (const auto& ip : test_output) { | ||
| EXPECT_EQ(0, trie_->getTags(Utility::parseInternetAddress(ip)).size()); |
There was a problem hiding this comment.
My only thought on the test refactor is that if multi-vector responses are coming, you may want to refactor expectIPAndTag to actually take a vector, rather than splitting this into "one string" "empty vector" and "multi-string response" test cases. Your call if it's easier this way.
There was a problem hiding this comment.
I was able to implement #2614 on top of this change by merging multiple results into a single vector. I think that will suffice for the IP tagging filter.
There was a problem hiding this comment.
I got rid of expectIPandNoTag() and kept ExpectIPandTags(). It checks the content of the tag vector against the expected vector, empty vectors are supported too!
Signed-off-by: Constance Caramanolis <ccaramanolis@lyft.com>
Signed-off-by: Constance Caramanolis ccaramanolis@lyft.com
Description:
The LC-Trie would only return a single tag because nested prefixes was not supported yet. To unblock nested prefixes, the getTag methods have been changed to getTags and return a vector of strings.
Risk Level: Low - change interface for class that isn't consumed yet.
Testing: Existing unit tests have been updated to expect vectors.
Docs Changes: N/A
Release Notes: N/A