diff --git a/ent/encryption/encryption.cc b/ent/encryption/encryption.cc index 476e1354f8..4904bc5cdd 100644 --- a/ent/encryption/encryption.cc +++ b/ent/encryption/encryption.cc @@ -475,6 +475,14 @@ public: for (auto&& [id, h] : _per_thread_kmip_host_cache[this_shard_id()]) { co_await h->disconnect(); } + static auto stop_all = [](auto&& cache) -> future<> { + for (auto& [k, host] : cache) { + co_await host->stop(); + } + }; + co_await stop_all(_per_thread_kms_host_cache[this_shard_id()]); + co_await stop_all(_per_thread_gcp_host_cache[this_shard_id()]); + _per_thread_provider_cache[this_shard_id()].clear(); _per_thread_system_key_cache[this_shard_id()].clear(); _per_thread_kmip_host_cache[this_shard_id()].clear(); diff --git a/ent/encryption/gcp_host.cc b/ent/encryption/gcp_host.cc index 1faca24e70..69b138985d 100644 --- a/ent/encryption/gcp_host.cc +++ b/ent/encryption/gcp_host.cc @@ -101,6 +101,7 @@ public: ~impl() = default; future<> init(); + future<> stop(); const host_options& options() const { return _options; } @@ -840,6 +841,11 @@ future<> encryption::gcp_host::impl::init() { _initialized = true; } +future<> encryption::gcp_host::impl::stop() { + co_await _attr_cache.stop(); + co_await _id_cache.stop(); +} + std::tuple encryption::gcp_host::impl::parse_key(std::string_view spec) { auto i = spec.find_last_of('/'); if (i == std::string_view::npos) { @@ -1002,6 +1008,10 @@ future<> encryption::gcp_host::init() { return _impl->init(); } +future<> encryption::gcp_host::stop() { + return _impl->stop(); +} + const encryption::gcp_host::host_options& encryption::gcp_host::options() const { return _impl->options(); } diff --git a/ent/encryption/gcp_host.hh b/ent/encryption/gcp_host.hh index 8764c0d24a..8821a9d0f6 100644 --- a/ent/encryption/gcp_host.hh +++ b/ent/encryption/gcp_host.hh @@ -65,6 +65,8 @@ public: ~gcp_host(); future<> init(); + future<> stop(); + const host_options& options() const; struct option_override : public t_credentials_source> { diff --git a/ent/encryption/kmip_host.cc b/ent/encryption/kmip_host.cc index c39fce964b..910c4b5178 100644 --- a/ent/encryption/kmip_host.cc +++ b/ent/encryption/kmip_host.cc @@ -724,9 +724,11 @@ future<> kmip_host::impl::connect() { } future<> kmip_host::impl::disconnect() { - return do_for_each(_options.hosts, [this](const sstring& host) { + co_await do_for_each(_options.hosts, [this](const sstring& host) { return clear_connections(host); }); + co_await _attr_cache.stop(); + co_await _id_cache.stop(); } static unsigned from_str(unsigned (*f)(char*, int, int*), const sstring& s, const sstring& what) { diff --git a/ent/encryption/kms_host.cc b/ent/encryption/kms_host.cc index 2827f54efa..0d856841db 100644 --- a/ent/encryption/kms_host.cc +++ b/ent/encryption/kms_host.cc @@ -160,6 +160,8 @@ public: ~impl() = default; future<> init(); + future<> stop(); + const host_options& options() const { return _options; } @@ -988,6 +990,11 @@ future<> encryption::kms_host::impl::init() { _initialized = true; } +future<> encryption::kms_host::impl::stop() { + co_await _attr_cache.stop(); + co_await _id_cache.stop(); +} + future encryption::kms_host::impl::create_key(const attr_cache_key& k) { auto& master_key = k.master_key; auto& aws_assume_role_arn = k.aws_assume_role_arn; @@ -1150,6 +1157,10 @@ future<> encryption::kms_host::init() { return _impl->init(); } +future<> encryption::kms_host::stop() { + return _impl->stop(); +} + const encryption::kms_host::host_options& encryption::kms_host::options() const { return _impl->options(); } diff --git a/ent/encryption/kms_host.hh b/ent/encryption/kms_host.hh index ac9fd1de41..2594578018 100644 --- a/ent/encryption/kms_host.hh +++ b/ent/encryption/kms_host.hh @@ -63,6 +63,8 @@ public: ~kms_host(); future<> init(); + future<> stop(); + const host_options& options() const; struct option_override {