From 1d07d766506d48e97ea1483589ec0dca18db736b Mon Sep 17 00:00:00 2001 From: Andrew Wong Date: Thu, 30 May 2024 18:17:35 -0700 Subject: [PATCH 1/3] admin: fix cache trim parameter order The arguments are reversed. (cherry picked from commit 1d6f3884c7d9991846c84b095d8d39bacce693ba) --- src/v/redpanda/admin/server.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/v/redpanda/admin/server.cc b/src/v/redpanda/admin/server.cc index b5533f81b68ae..f2021a6b48082 100644 --- a/src/v/redpanda/admin/server.cc +++ b/src/v/redpanda/admin/server.cc @@ -4061,13 +4061,13 @@ admin_server::delete_cloud_storage_lifecycle( ss::future admin_server::post_cloud_storage_cache_trim( std::unique_ptr req) { - auto size_limit = get_integer_query_param(*req, "objects"); - auto bytes_limit = static_cast>( + auto max_objects = get_integer_query_param(*req, "objects"); + auto max_bytes = static_cast>( get_integer_query_param(*req, "bytes")); co_await _cloud_storage_cache.invoke_on( - ss::shard_id{0}, [size_limit, bytes_limit](auto& c) { - return c.trim_manually(size_limit, bytes_limit); + ss::shard_id{0}, [max_objects, max_bytes](auto& c) { + return c.trim_manually(max_bytes, max_objects); }); co_return ss::json::json_return_type(ss::json::json_void()); From 0dfb5892a90d8b2db52ae99e605e67671326e9a5 Mon Sep 17 00:00:00 2001 From: Andrew Wong Date: Thu, 30 May 2024 18:21:50 -0700 Subject: [PATCH 2/3] cloud_storage: log about manual trim We don't expect these to be frequent by any means. It's useful to know about the input parameters, e.g. in case there's a bug in running it. (cherry picked from commit 3fd9135f92c86d996f524589ed555fe9214cf266) --- src/v/cloud_storage/cache_service.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/v/cloud_storage/cache_service.cc b/src/v/cloud_storage/cache_service.cc index 6ad83e5de5e17..0ca0f6cf441f5 100644 --- a/src/v/cloud_storage/cache_service.cc +++ b/src/v/cloud_storage/cache_service.cc @@ -290,6 +290,12 @@ ss::future<> cache::trim_manually( std::optional object_limit_override) { vassert(ss::this_shard_id() == 0, "Method can only be invoked on shard 0"); auto units = co_await ss::get_units(_cleanup_sm, 1); + vlog( + cst_log.info, + "Beginning manual trim, requested bytes limit: {}, requested object " + "limit: {}", + size_limit_override, + object_limit_override); co_return co_await trim(size_limit_override, object_limit_override); } From 74637f5c212ecf2dbca6629f7d06edd6b8a18c20 Mon Sep 17 00:00:00 2001 From: Andrew Wong Date: Thu, 30 May 2024 19:14:02 -0700 Subject: [PATCH 3/3] admin: fix some incorrect stoi usages CONFLICT: - uses [] instead of get_param from httpd - get_integer_query_param() returns a uint64_t - revision ids are int64_t (cherry picked from commit a6fcac50af50e76140ff102192871074e627fba9) --- src/v/redpanda/admin/server.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/v/redpanda/admin/server.cc b/src/v/redpanda/admin/server.cc index f2021a6b48082..29cf939069252 100644 --- a/src/v/redpanda/admin/server.cc +++ b/src/v/redpanda/admin/server.cc @@ -476,7 +476,7 @@ get_integer_query_param(const ss::http::request& req, std::string_view name) { const ss::sstring& str_param = req.query_parameters.at(key); try { - return std::stoi(str_param); + return std::stoull(str_param); } catch (const std::invalid_argument&) { throw ss::httpd::bad_request_exception( fmt::format("Parameter {} must be an integer", name)); @@ -4042,7 +4042,7 @@ admin_server::delete_cloud_storage_lifecycle( model::initial_revision_id revision; try { revision = model::initial_revision_id( - std::stoi(req->param["revision"])); + std::stoll(req->param["revision"])); } catch (...) { throw ss::httpd::bad_param_exception(fmt::format( "Revision id must be an integer: {}", req->param["revision"]));