Skip to content

Commit

Permalink
Revert "redis_proxy: fix crash if catch_all_route is not defined (#29138
Browse files Browse the repository at this point in the history
) (#29221)

Revert "redis_proxy: fix crash if catch_all_route is not defined (#29138)"

This reverts commit 1438a10.

Signed-off-by: Ryan Northey <[email protected]>
  • Loading branch information
phlax authored Aug 23, 2023
1 parent ea04ada commit 64a45c4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 23 deletions.
3 changes: 0 additions & 3 deletions changelogs/current.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ bug_fixes:
- area: extension_discovery_service
change: |
Fixed a bug causing crash if ECDS is used with upstream HTTP filters.
- area: redis_proxy
change: |
Fixed a bug causing crash if incoming redis key does not match against a prefix_route and catch_all_route is not defined.
- area: tls
change: |
fixed a bug where handshake may fail when both private key provider and cert validation are set.
Expand Down
10 changes: 3 additions & 7 deletions source/extensions/filters/network/redis_proxy/router_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,10 @@ RouteSharedPtr PrefixRoutes::upstreamPool(std::string& key,
} else {
value = prefix_lookup_table_.findLongestPrefix(key.c_str());
}

if (value == nullptr) {
// prefix route not found, check if catch_all_route is defined to fallback to.
if (catch_all_route_ != nullptr) {
value = catch_all_route_;
} else {
// no route found.
return value;
}
// prefix route not found, default to catch all route.
value = catch_all_route_;
}

if (value->removePrefix()) {
Expand Down
13 changes: 0 additions & 13 deletions test/extensions/filters/network/redis_proxy/router_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,6 @@ createPrefixRoutes() {
return prefix_routes;
}

TEST(PrefixRoutesTest, MissingCatchAll) {
Upstreams upstreams;
upstreams.emplace("fake_clusterA", std::make_shared<ConnPool::MockInstance>());
upstreams.emplace("fake_clusterB", std::make_shared<ConnPool::MockInstance>());

Runtime::MockLoader runtime_;

PrefixRoutes router(createPrefixRoutes(), std::move(upstreams), runtime_);

std::string key("c:bar");
EXPECT_EQ(nullptr, router.upstreamPool(key));
}

TEST(PrefixRoutesTest, RoutedToCatchAll) {
auto upstream_c = std::make_shared<ConnPool::MockInstance>();

Expand Down

0 comments on commit 64a45c4

Please sign in to comment.