From 767c7ed9a58f62f8106481856c56a2aff75ed44b Mon Sep 17 00:00:00 2001 From: Jarno Rajahalme Date: Tue, 3 Dec 2024 13:10:46 +0100 Subject: [PATCH] policy: Change remaining main thread asserts into error logs Signed-off-by: Jarno Rajahalme --- cilium/network_policy.h | 7 ++++++- cilium/secret_watcher.cc | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cilium/network_policy.h b/cilium/network_policy.h index 575cc42f2..8a50f41cc 100644 --- a/cilium/network_policy.h +++ b/cilium/network_policy.h @@ -109,7 +109,12 @@ class IPAddressPair { class PolicyInstance { public: - virtual ~PolicyInstance() { ASSERT_IS_MAIN_OR_TEST_THREAD(); }; + virtual ~PolicyInstance() { + if (!Thread::MainThread::isMainOrTestThread()) { + ENVOY_LOG_MISC(error, "PolicyInstance: Destructor executing in a worker thread, while " + "only main thread should destruct xDS resources"); + } + }; virtual bool allowed(bool ingress, uint32_t remote_id, uint16_t port, Envoy::Http::RequestHeaderMap& headers, diff --git a/cilium/secret_watcher.cc b/cilium/secret_watcher.cc index bf25d73a6..bd81e637b 100644 --- a/cilium/secret_watcher.cc +++ b/cilium/secret_watcher.cc @@ -35,7 +35,10 @@ SecretWatcher::SecretWatcher(const NetworkPolicyMap& parent, const std::string& update_secret_(readAndWatchSecret()) {} SecretWatcher::~SecretWatcher() { - ASSERT_IS_MAIN_OR_TEST_THREAD(); + if (!Thread::MainThread::isMainOrTestThread()) { + ENVOY_LOG(error, "SecretWatcher: Destructor executing in a worker thread, while " + "only main thread should destruct xDS resources"); + } delete load(); }