From 55304d2e5e7cb418686fa3c50b1794551b687cc3 Mon Sep 17 00:00:00 2001 From: Tam Mach Date: Sun, 22 Oct 2023 22:49:25 +1100 Subject: [PATCH] cilium: Adjust onConfigUpdate signature Relates: https://github.com/envoyproxy/envoy/pull/29439 Signed-off-by: Tam Mach --- cilium/host_map.cc | 6 ++++-- cilium/host_map.h | 11 ++++++----- cilium/network_policy.cc | 7 ++++--- cilium/network_policy.h | 11 ++++++----- tests/cilium_http_integration_test.cc | 7 +++---- tests/cilium_network_policy_test.cc | 5 +++-- 6 files changed, 26 insertions(+), 21 deletions(-) diff --git a/cilium/host_map.cc b/cilium/host_map.cc index f4330703f..7c75a2114 100644 --- a/cilium/host_map.cc +++ b/cilium/host_map.cc @@ -159,8 +159,9 @@ void PolicyHostMap::startSubscription(Server::Configuration::CommonFactoryContex subscription_->start({}); } -void PolicyHostMap::onConfigUpdate(const std::vector& resources, - const std::string& version_info) { +absl::Status +PolicyHostMap::onConfigUpdate(const std::vector& resources, + const std::string& version_info) { ENVOY_LOG(debug, "PolicyHostMap::onConfigUpdate({}), {} resources, version: {}", name_, resources.size(), version_info); @@ -189,6 +190,7 @@ void PolicyHostMap::onConfigUpdate(const std::vector& resources, - const std::string& version_info) override; - void onConfigUpdate(const std::vector& added_resources, - const Protobuf::RepeatedPtrField& removed_resources, - const std::string& system_version_info) override { + absl::Status onConfigUpdate(const std::vector& resources, + const std::string& version_info) override; + absl::Status onConfigUpdate(const std::vector& added_resources, + const Protobuf::RepeatedPtrField& removed_resources, + const std::string& system_version_info) override { // NOT IMPLEMENTED YET. UNREFERENCED_PARAMETER(added_resources); UNREFERENCED_PARAMETER(removed_resources); UNREFERENCED_PARAMETER(system_version_info); + return absl::OkStatus(); } void onConfigUpdateFailed(Envoy::Config::ConfigUpdateFailureReason, const EnvoyException* e) override; diff --git a/cilium/network_policy.cc b/cilium/network_policy.cc index dc607d7fe..75f2ab953 100644 --- a/cilium/network_policy.cc +++ b/cilium/network_policy.cc @@ -775,9 +775,9 @@ void ThreadLocalPolicyMap::Update(std::vector& resources, - const std::string& version_info) { +absl::Status +NetworkPolicyMap::onConfigUpdate(const std::vector& resources, + const std::string& version_info) { ENVOY_LOG(debug, "NetworkPolicyMap::onConfigUpdate({}), {} resources, version: {}", name_, resources.size(), version_info); @@ -932,6 +932,7 @@ void NetworkPolicyMap::onConfigUpdate( #pragma clang diagnostic ignored "-Wnull-dereference" transport_factory_context_->setInitManager(*static_cast(nullptr)); #pragma clang diagnostic pop + return absl::OkStatus(); } void NetworkPolicyMap::onConfigUpdateFailed(Envoy::Config::ConfigUpdateFailureReason, diff --git a/cilium/network_policy.h b/cilium/network_policy.h index 40b82fa12..fe92e2ab6 100644 --- a/cilium/network_policy.h +++ b/cilium/network_policy.h @@ -144,15 +144,16 @@ class NetworkPolicyMap : public Singleton::Instance, void runAfterAllThreads(std::function) const; // Config::SubscriptionCallbacks - void onConfigUpdate(const std::vector& resources, - const std::string& version_info) override; - void onConfigUpdate(const std::vector& added_resources, - const Protobuf::RepeatedPtrField& removed_resources, - const std::string& system_version_info) override { + absl::Status onConfigUpdate(const std::vector& resources, + const std::string& version_info) override; + absl::Status onConfigUpdate(const std::vector& added_resources, + const Protobuf::RepeatedPtrField& removed_resources, + const std::string& system_version_info) override { // NOT IMPLEMENTED YET. UNREFERENCED_PARAMETER(added_resources); UNREFERENCED_PARAMETER(removed_resources); UNREFERENCED_PARAMETER(system_version_info); + return absl::OkStatus(); } void onConfigUpdateFailed(Envoy::Config::ConfigUpdateFailureReason, const EnvoyException* e) override; diff --git a/tests/cilium_http_integration_test.cc b/tests/cilium_http_integration_test.cc index 3352fb092..1306dbf83 100644 --- a/tests/cilium_http_integration_test.cc +++ b/tests/cilium_http_integration_test.cc @@ -373,9 +373,8 @@ class HostMapTest : public CiliumHttpIntegrationTest { const auto decoded_resources = Envoy::Config::DecodedResourcesWrapper( host_decoder, message.resources(), message.version_info()); - EXPECT_THROW_WITH_MESSAGE( - hmap.onConfigUpdate(decoded_resources.refvec_, message.version_info()), EnvoyException, - exmsg); + EXPECT_EQ(hmap.onConfigUpdate(decoded_resources.refvec_, message.version_info()).message(), + exmsg); tls.shutdownGlobalThreading(); } }; @@ -411,7 +410,7 @@ TEST_P(HostMapTest, HostMapValid) { const auto decoded_resources = Envoy::Config::DecodedResourcesWrapper( host_decoder, message.resources(), message.version_info()); - VERBOSE_EXPECT_NO_THROW(hmap->onConfigUpdate(decoded_resources.refvec_, message.version_info())); + EXPECT_TRUE(hmap->onConfigUpdate(decoded_resources.refvec_, message.version_info()).ok()); EXPECT_EQ(hmap->resolve(Network::Address::Ipv4Instance("192.168.0.1").ip()), 173); EXPECT_EQ(hmap->resolve(Network::Address::Ipv4Instance("192.168.0.0").ip()), 12); diff --git a/tests/cilium_network_policy_test.cc b/tests/cilium_network_policy_test.cc index 80f69d2dd..ac6577c7f 100644 --- a/tests/cilium_network_policy_test.cc +++ b/tests/cilium_network_policy_test.cc @@ -52,7 +52,8 @@ class CiliumNetworkPolicyTest : public ::testing::Test { NetworkPolicyDecoder network_policy_decoder; const auto decoded_resources = Config::DecodedResourcesWrapper( network_policy_decoder, message.resources(), message.version_info()); - policy_map_->onConfigUpdate(decoded_resources.refvec_, message.version_info()); + EXPECT_TRUE( + policy_map_->onConfigUpdate(decoded_resources.refvec_, message.version_info()).ok()); return message.version_info(); } @@ -83,7 +84,7 @@ class CiliumNetworkPolicyTest : public ::testing::Test { }; TEST_F(CiliumNetworkPolicyTest, EmptyPolicyUpdate) { - EXPECT_NO_THROW(policy_map_->onConfigUpdate({}, "1")); + EXPECT_TRUE(policy_map_->onConfigUpdate({}, "1").ok()); } TEST_F(CiliumNetworkPolicyTest, SimplePolicyUpdate) {