From 64a45c4c8261b94a7ba57b87ed631643ae8fac51 Mon Sep 17 00:00:00 2001 From: phlax Date: Wed, 23 Aug 2023 19:34:51 +0100 Subject: [PATCH] Revert "redis_proxy: fix crash if catch_all_route is not defined (#29138) (#29221) Revert "redis_proxy: fix crash if catch_all_route is not defined (#29138)" This reverts commit 1438a10da220f32b3c29219c2afda42287e162cf. Signed-off-by: Ryan Northey --- changelogs/current.yaml | 3 --- .../filters/network/redis_proxy/router_impl.cc | 10 +++------- .../filters/network/redis_proxy/router_impl_test.cc | 13 ------------- 3 files changed, 3 insertions(+), 23 deletions(-) diff --git a/changelogs/current.yaml b/changelogs/current.yaml index af34362efbf9..0b21ee354c8e 100644 --- a/changelogs/current.yaml +++ b/changelogs/current.yaml @@ -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. diff --git a/source/extensions/filters/network/redis_proxy/router_impl.cc b/source/extensions/filters/network/redis_proxy/router_impl.cc index d553ae80e638..40e43322e872 100644 --- a/source/extensions/filters/network/redis_proxy/router_impl.cc +++ b/source/extensions/filters/network/redis_proxy/router_impl.cc @@ -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()) { diff --git a/test/extensions/filters/network/redis_proxy/router_impl_test.cc b/test/extensions/filters/network/redis_proxy/router_impl_test.cc index dcf6d3b3c59f..ec0681170378 100644 --- a/test/extensions/filters/network/redis_proxy/router_impl_test.cc +++ b/test/extensions/filters/network/redis_proxy/router_impl_test.cc @@ -50,19 +50,6 @@ createPrefixRoutes() { return prefix_routes; } -TEST(PrefixRoutesTest, MissingCatchAll) { - Upstreams upstreams; - upstreams.emplace("fake_clusterA", std::make_shared()); - upstreams.emplace("fake_clusterB", std::make_shared()); - - 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();