Skip to content

Commit

Permalink
debug: Assert policy destruction happens in the main thread
Browse files Browse the repository at this point in the history
Signed-off-by: Jarno Rajahalme <jarno@isovalent.com>
  • Loading branch information
jrajahalme committed Nov 21, 2024
1 parent 9a53218 commit 7db67de
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion cilium/network_policy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ class HeaderMatch : public Logger::Loggable<Logger::Id::config> {
HeaderMatch(const NetworkPolicyMap& parent, const cilium::HeaderMatch& config)
: name_(config.name()), value_(config.value()), match_action_(config.match_action()),
mismatch_action_(config.mismatch_action()) {
ASSERT_IS_MAIN_OR_TEST_THREAD();
if (config.value_sds_secret().length() > 0)
secret_ = std::make_unique<SecretWatcher>(parent, config.value_sds_secret());
}

~HeaderMatch() {
ASSERT_IS_MAIN_OR_TEST_THREAD();
}

void logRejected(Cilium::AccessLog::Entry& log_entry, absl::string_view value) const {
log_entry.AddRejected(name_.get(), !secret_ ? value : "[redacted]");
}
Expand Down
9 changes: 7 additions & 2 deletions cilium/secret_watcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ void resetSDSConfigFunc() { getSDSConfig = &getCiliumSDSConfig; }
SecretWatcher::SecretWatcher(const NetworkPolicyMap& parent, const std::string& sds_name)
: parent_(parent), name_(sds_name),
secret_provider_(secretProvider(parent.transportFactoryContext(), sds_name)),
update_secret_(readAndWatchSecret()) {}
update_secret_(readAndWatchSecret()) {
ASSERT_IS_MAIN_OR_TEST_THREAD();
}

SecretWatcher::~SecretWatcher() { delete load(); }
SecretWatcher::~SecretWatcher() {
ASSERT_IS_MAIN_OR_TEST_THREAD();
delete load();
}

Envoy::Common::CallbackHandlePtr SecretWatcher::readAndWatchSecret() {
THROW_IF_NOT_OK(store());
Expand Down

0 comments on commit 7db67de

Please sign in to comment.