From d0cde0232b3f8903eb8a036f76aaefb402b0d8e5 Mon Sep 17 00:00:00 2001 From: Michal Maslanka Date: Thu, 9 Nov 2023 16:11:29 +0100 Subject: [PATCH] chore: fixed building with clang-17 The two changes were required to build Redpanda with clang-17. 1. Do not catch `ss::sleep_aborted_exception` when `ss::abort_requested` is already captured. As `ss::sleep_aborted_exception` inherits from more general `ss::abort_requested_exception` it is already handled 2. Boost `boost::basic_static_string` is not longer implicitly convertible to `std::string_view` Signed-off-by: Michal Maslanka --- src/v/archival/ntp_archiver_service.cc | 3 --- src/v/cloud_roles/request_response_helpers.cc | 2 +- src/v/cluster/log_eviction_stm.cc | 2 -- src/v/cluster/metrics_reporter.cc | 2 +- src/v/http/demo/client.cc | 2 +- src/v/http/tests/http_client_test.cc | 27 +++++++++---------- src/v/pandaproxy/test/utils.h | 3 ++- src/v/ssx/future-util.h | 3 --- 8 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/v/archival/ntp_archiver_service.cc b/src/v/archival/ntp_archiver_service.cc index bc1ae5f5fd96e..1d57d6e1ce5ef 100644 --- a/src/v/archival/ntp_archiver_service.cc +++ b/src/v/archival/ntp_archiver_service.cc @@ -364,7 +364,6 @@ ss::future<> ntp_archiver::upload_until_abort() { _conf->upload_scheduling_group, [this] { return upload_until_term_change(); }) .handle_exception_type([](const ss::abort_requested_exception&) {}) - .handle_exception_type([](const ss::sleep_aborted&) {}) .handle_exception_type([](const ss::gate_closed_exception&) {}) .handle_exception_type([](const ss::broken_semaphore&) {}) .handle_exception_type([](const ss::broken_named_semaphore&) {}) @@ -429,7 +428,6 @@ ss::future<> ntp_archiver::sync_manifest_until_abort() { [](const ss::abort_requested_exception&) {}) .handle_exception_type([](const ss::broken_semaphore&) {}) .handle_exception_type([](const ss::broken_named_semaphore&) {}) - .handle_exception_type([](const ss::sleep_aborted&) {}) .handle_exception_type([](const ss::gate_closed_exception&) {}); } catch (const ss::semaphore_timed_out& e) { vlog( @@ -2138,7 +2136,6 @@ ss::future<> ntp_archiver::housekeeping() { co_await apply_spillover(); } } catch (const ss::abort_requested_exception&) { - } catch (const ss::sleep_aborted&) { } catch (const ss::gate_closed_exception&) { } catch (const ss::broken_semaphore&) { } catch (const ss::semaphore_timed_out&) { diff --git a/src/v/cloud_roles/request_response_helpers.cc b/src/v/cloud_roles/request_response_helpers.cc index 7c9b3faf777ef..cfca0fad6618d 100644 --- a/src/v/cloud_roles/request_response_helpers.cc +++ b/src/v/cloud_roles/request_response_helpers.cc @@ -117,7 +117,7 @@ ss::future make_request_with_payload( std::optional timeout) { req.set( boost::beast::http::field::content_length, - boost::beast::to_static_string(content.size_bytes())); + fmt::format("{}", content.size_bytes())); auto stream = make_iobuf_input_stream(std::move(content)); auto tout = timeout.value_or( diff --git a/src/v/cluster/log_eviction_stm.cc b/src/v/cluster/log_eviction_stm.cc index 2c6e450dcdb22..442748104f9e7 100644 --- a/src/v/cluster/log_eviction_stm.cc +++ b/src/v/cluster/log_eviction_stm.cc @@ -120,8 +120,6 @@ ss::future<> log_eviction_stm::handle_log_eviction_events() { } catch (const ss::gate_closed_exception&) { // ignore gate closed exception, shutting down } catch (const ss::broken_semaphore&) { - } catch (const ss::sleep_aborted&) { - // ignore broken sem exception, shutting down } catch (const std::exception& e) { vlog( _log.error, diff --git a/src/v/cluster/metrics_reporter.cc b/src/v/cluster/metrics_reporter.cc index 369d189bfbe9e..badbc4a9cc346 100644 --- a/src/v/cluster/metrics_reporter.cc +++ b/src/v/cluster/metrics_reporter.cc @@ -168,7 +168,7 @@ metrics_reporter::make_header(const iobuf& buffer) { header.target(std::string(_address.path)); header.insert( boost::beast::http::field::content_length, - boost::beast::to_static_string(buffer.size_bytes())); + fmt::format("{}", buffer.size_bytes())); header.insert( boost::beast::http::field::host, fmt::format("{}:{}", _address.host, _address.port)); diff --git a/src/v/http/demo/client.cc b/src/v/http/demo/client.cc index 1b6915ad3d793..4603be0809b91 100644 --- a/src/v/http/demo/client.cc +++ b/src/v/http/demo/client.cc @@ -99,7 +99,7 @@ http::client::request_header make_header(const test_conf& cfg) { header.target(cfg.target); header.insert( boost::beast::http::field::content_length, - boost::beast::to_static_string(cfg.data.length())); + fmt::format("{}", cfg.data.length())); auto host = fmt::format("{}", cfg.client_cfg.server_addr); header.insert(boost::beast::http::field::host, host); header.insert(boost::beast::http::field::content_type, "application/json"); diff --git a/src/v/http/tests/http_client_test.cc b/src/v/http/tests/http_client_test.cc index 2aa5719e903ee..fde69812693f8 100644 --- a/src/v/http/tests/http_client_test.cc +++ b/src/v/http/tests/http_client_test.cc @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -188,7 +189,7 @@ SEASTAR_THREAD_TEST_CASE(test_http_POST_roundtrip) { header.target("/echo"); header.insert( boost::beast::http::field::content_length, - boost::beast::to_static_string(std::strlen(httpd_server_reply))); + fmt::format("{}", std::strlen(httpd_server_reply))); header_set_host(header, config.server_addr); header.insert(boost::beast::http::field::content_type, "application/json"); test_http_request( @@ -251,8 +252,7 @@ SEASTAR_THREAD_TEST_CASE(test_http_GET_streaming_roundtrip) { header.method(boost::beast::http::verb::get); header.target("/get"); header.insert( - boost::beast::http::field::content_length, - boost::beast::to_static_string(0)); + boost::beast::http::field::content_length, fmt::format("{}", 0)); header_set_host(header, config.server_addr); header.insert(boost::beast::http::field::content_type, "application/json"); constexpr size_t skip_bytes = 100; @@ -281,7 +281,7 @@ SEASTAR_THREAD_TEST_CASE(test_http_POST_streaming_roundtrip) { header.target("/echo"); header.insert( boost::beast::http::field::content_length, - boost::beast::to_static_string(std::strlen(httpd_server_reply))); + fmt::format("{}", std::strlen(httpd_server_reply))); header_set_host(header, config.server_addr); header.insert(boost::beast::http::field::content_type, "application/json"); @@ -351,7 +351,7 @@ SEASTAR_THREAD_TEST_CASE(test_http_PUT_roundtrip) { header.target("/put"); header.insert( boost::beast::http::field::content_length, - boost::beast::to_static_string(std::strlen(httpd_server_reply))); + fmt::format("{}", std::strlen(httpd_server_reply))); header_set_host(header, config.server_addr); header.insert(boost::beast::http::field::content_type, "application/json"); test_http_request( @@ -374,8 +374,7 @@ SEASTAR_THREAD_TEST_CASE(test_http_PUT_empty_roundtrip) { header.method(boost::beast::http::verb::put); header.target("/empty"); header.insert( - boost::beast::http::field::content_length, - boost::beast::to_static_string(0)); + boost::beast::http::field::content_length, fmt::format("{}", 0)); header_set_host(header, config.server_addr); header.insert(boost::beast::http::field::content_type, "application/json"); iobuf empty; @@ -562,7 +561,7 @@ SEASTAR_THREAD_TEST_CASE(test_http_via_impostor) { request_header.target("/"); request_header.insert( boost::beast::http::field::content_length, - boost::beast::to_static_string(std::strlen(httpd_server_reply))); + fmt::format("{}", std::strlen(httpd_server_reply))); header_set_host(request_header, config.server_addr); request_header.insert( boost::beast::http::field::content_type, "application/json"); @@ -574,7 +573,7 @@ SEASTAR_THREAD_TEST_CASE(test_http_via_impostor) { header_set_host(resp_hdr, config.server_addr); resp_hdr.insert( boost::beast::http::field::content_length, - boost::beast::to_static_string(response_data.size())); + fmt::format("{}", response_data.size())); auto full_response = get_response_header(resp_hdr) + response_data; // Run test case @@ -603,7 +602,7 @@ SEASTAR_THREAD_TEST_CASE(test_http_via_impostor_incorrect_reply) { request_header.target("/"); request_header.insert( boost::beast::http::field::content_length, - boost::beast::to_static_string(std::strlen(httpd_server_reply))); + fmt::format("{}", std::strlen(httpd_server_reply))); header_set_host(request_header, config.server_addr); request_header.insert( boost::beast::http::field::content_type, "application/json"); @@ -639,7 +638,7 @@ SEASTAR_THREAD_TEST_CASE(test_http_via_impostor_chunked_encoding) { request_header.target("/"); request_header.insert( boost::beast::http::field::content_length, - boost::beast::to_static_string(std::strlen(httpd_server_reply))); + fmt::format("{}", std::strlen(httpd_server_reply))); header_set_host(request_header, config.server_addr); request_header.insert( boost::beast::http::field::content_type, "application/json"); @@ -704,7 +703,7 @@ void run_framing_test_using_impostor( request_header.target("/"); request_header.insert( boost::beast::http::field::content_length, - boost::beast::to_static_string(std::strlen(httpd_server_reply))); + fmt::format("{}", std::strlen(httpd_server_reply))); header_set_host(request_header, config.server_addr); request_header.insert( boost::beast::http::field::content_type, "application/json"); @@ -719,7 +718,7 @@ void run_framing_test_using_impostor( } else { resp_hdr.insert( boost::beast::http::field::content_length, - boost::beast::to_static_string(response_data.size())); + fmt::format("{}", response_data.size())); } header_set_host(resp_hdr, config.server_addr); auto header_str = get_response_header(resp_hdr); @@ -795,7 +794,7 @@ SEASTAR_THREAD_TEST_CASE(test_http_via_impostor_no_content_length) { request_header.target("/"); request_header.insert( boost::beast::http::field::content_length, - boost::beast::to_static_string(std::strlen(httpd_server_reply))); + fmt::format("{}", std::strlen(httpd_server_reply))); header_set_host(request_header, config.server_addr); request_header.insert( boost::beast::http::field::content_type, "application/json"); diff --git a/src/v/pandaproxy/test/utils.h b/src/v/pandaproxy/test/utils.h index 41302e5f010b1..d9530d99fde20 100644 --- a/src/v/pandaproxy/test/utils.h +++ b/src/v/pandaproxy/test/utils.h @@ -14,6 +14,7 @@ #include "pandaproxy/json/types.h" #include +#include #include using serialization_format = pandaproxy::json::serialization_format; @@ -50,7 +51,7 @@ inline http::client::request_header make_header( hdr.target(target); hdr.insert( boost::beast::http::field::content_length, - boost::beast::to_static_string(body.size_bytes())); + fmt::format("{}", body.size_bytes())); if (content != serialization_format::none) { hdr.insert( boost::beast::http::field::content_type, to_header_value(content)); diff --git a/src/v/ssx/future-util.h b/src/v/ssx/future-util.h index 2e81d709dd283..452667114fdcc 100644 --- a/src/v/ssx/future-util.h +++ b/src/v/ssx/future-util.h @@ -276,7 +276,6 @@ ignore_shutdown_exceptions(seastar::future<> fut) noexcept { } catch (const seastar::broken_semaphore&) { } catch (const seastar::broken_promise&) { } catch (const seastar::broken_condition_variable&) { - } catch (const seastar::sleep_aborted&) { } } @@ -294,8 +293,6 @@ inline bool is_shutdown_exception(const std::exception_ptr& e) { return true; } catch (const seastar::broken_condition_variable&) { return true; - } catch (const seastar::sleep_aborted&) { - return true; } catch (...) { } return false;