Skip to content

Commit

Permalink
Merge pull request redpanda-data#21582 from WillemKauf/guardrail_mani…
Browse files Browse the repository at this point in the history
…fest

cloud_storage: add `topic_mount_manifest`
  • Loading branch information
WillemKauf authored Jul 31, 2024
2 parents 3fabf22 + bbd86d4 commit 45b4cc1
Show file tree
Hide file tree
Showing 21 changed files with 811 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/v/cloud_storage/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ redpanda_cc_library(
"segment_state.cc",
"topic_manifest.cc",
"topic_manifest_downloader.cc",
"topic_mount_handler.cc",
"topic_mount_manifest.cc",
"topic_path_utils.cc",
"tx_range_manifest.cc",
"types.cc",
Expand Down Expand Up @@ -105,6 +107,8 @@ redpanda_cc_library(
"spillover_manifest.h",
"topic_manifest.h",
"topic_manifest_downloader.h",
"topic_mount_handler.h",
"topic_mount_manifest.h",
"topic_path_utils.h",
"tx_range_manifest.h",
"types.h",
Expand Down
2 changes: 2 additions & 0 deletions src/v/cloud_storage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ v_cc_library(
access_time_tracker.cc
cache_probe.cc
download_exception.cc
topic_mount_manifest.cc
partition_manifest.cc
partition_manifest_downloader.cc
partition_path_utils.cc
Expand Down Expand Up @@ -44,6 +45,7 @@ v_cc_library(
segment_path_utils.cc
topic_manifest.cc
topic_manifest_downloader.cc
topic_mount_handler.cc
topic_path_utils.cc
async_manifest_view.cc
materialized_manifest_cache.cc
Expand Down
3 changes: 3 additions & 0 deletions src/v/cloud_storage/base_manifest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ std::ostream& operator<<(std::ostream& s, manifest_type t) {
case manifest_type::spillover:
s << "spillover";
break;
case manifest_type::topic_mount:
s << "topic_mount";
break;
}
return s;
}
Expand Down
1 change: 1 addition & 0 deletions src/v/cloud_storage/base_manifest.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ enum class manifest_type {
tx_range,
cluster_metadata,
spillover,
topic_mount
};

std::ostream& operator<<(std::ostream& s, manifest_type t);
Expand Down
1 change: 1 addition & 0 deletions src/v/cloud_storage/fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class remote_partition;
class remote_path_provider;
class remote_segment;
class partition_manifest;
class topic_mount_manifest;
class topic_manifest;
class partition_probe;
class async_manifest_view;
Expand Down
6 changes: 6 additions & 0 deletions src/v/cloud_storage/remote.cc
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ ss::future<download_result> remote::do_download_manifest(
case manifest_type::spillover:
_probe.spillover_manifest_download();
break;
case manifest_type::topic_mount:
_probe.topic_mount_manifest_download();
break;
}
co_return download_result::success;
} catch (...) {
Expand Down Expand Up @@ -383,6 +386,9 @@ ss::future<upload_result> remote::upload_manifest(
case manifest_type::spillover:
_probe.spillover_manifest_upload();
break;
case manifest_type::topic_mount:
_probe.topic_mount_manifest_upload();
break;
}
_probe.register_upload_size(size);
co_return upload_result::success;
Expand Down
9 changes: 9 additions & 0 deletions src/v/cloud_storage/remote_path_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "cloud_storage/remote_label.h"
#include "cloud_storage/segment_path_utils.h"
#include "cloud_storage/spillover_manifest.h"
#include "cloud_storage/topic_mount_manifest.h"
#include "cloud_storage/topic_path_utils.h"
#include "cloud_storage/types.h"
#include "model/fundamental.h"
Expand Down Expand Up @@ -116,6 +117,14 @@ ss::sstring remote_path_provider::spillover_manifest_path(
spillover_manifest::filename(c));
}

ss::sstring remote_path_provider::topic_mount_manifest_path(
const topic_mount_manifest& manifest) const {
return fmt::format(
"migration/{}/{}",
manifest.get_source_label().cluster_uuid,
manifest.get_tp_ns().path());
}

ss::sstring remote_path_provider::segment_path(
const model::ntp& ntp,
model::initial_revision_id rev,
Expand Down
3 changes: 3 additions & 0 deletions src/v/cloud_storage/remote_path_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class remote_path_provider {
const partition_manifest& stm_manifest,
const spillover_manifest_path_components& c) const;

ss::sstring
topic_mount_manifest_path(const topic_mount_manifest& manifest) const;

// Segment paths.
ss::sstring segment_path(
const partition_manifest& manifest, const segment_meta& segment) const;
Expand Down
22 changes: 22 additions & 0 deletions src/v/cloud_storage/remote_probe.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,24 @@ class remote_probe {
return _cnt_tx_manifest_downloads;
}

/// Register manifest (re)upload
void topic_mount_manifest_upload() { _cnt_topic_mount_manifest_uploads++; }

/// Get manifest (re)upload
uint64_t get_topic_mount_manifest_uploads() const {
return _cnt_topic_mount_manifest_uploads;
}

/// Register manifest download
void topic_mount_manifest_download() {
_cnt_topic_mount_manifest_downloads++;
}

/// Get manifest download
uint64_t get_topic_mount_manifest_downloads() const {
return _cnt_topic_mount_manifest_downloads;
}

/// Register backof invocation during manifest upload
void manifest_upload_backoff() { _cnt_manifest_upload_backoff++; }

Expand Down Expand Up @@ -295,6 +313,10 @@ class remote_probe {
uint64_t _cnt_spillover_manifest_uploads{0};
/// Number of spillover manifest downloads
uint64_t _cnt_spillover_manifest_downloads{0};
/// Number of topic_mount manifest uploads
uint64_t _cnt_topic_mount_manifest_uploads{0};
/// Number of topic_mount manifest downloads
uint64_t _cnt_topic_mount_manifest_downloads{0};

hist_t _client_acquisition_latency;
hist_t _segment_download_latency;
Expand Down
20 changes: 20 additions & 0 deletions src/v/cloud_storage/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@ rp_test(
LABELS cloud_storage
)

rp_test(
UNIT_TEST
GTEST
BINARY_NAME gtest_cloud_storage
SOURCES
topic_mount_manifest_test.cc
LIBRARIES
v::gtest_main
v::seastar_testing_main
v::cloud_storage
v::storage_test_utils
v::cloud_roles
v::application
v::kafka_test_utils
v::http_test_utils
ARGS "-- -c 1"
LABELS cloud_storage
)

rp_test(
UNIT_TEST
BINARY_NAME topic_manifest
Expand Down Expand Up @@ -85,6 +104,7 @@ rp_test(
s3_imposter.cc
topic_manifest_downloader_test.cc
topic_namespace_override_recovery_test.cc
topic_mount_handler_test.cc
util.cc
LIBRARIES
v::gtest_main
Expand Down
9 changes: 9 additions & 0 deletions src/v/cloud_storage/tests/remote_path_provider_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "cloud_storage/partition_manifest.h"
#include "cloud_storage/remote_path_provider.h"
#include "cloud_storage/spillover_manifest.h"
#include "cloud_storage/topic_mount_manifest.h"
#include "cloud_storage/topic_path_utils.h"
#include "cloud_storage/types.h"
#include "gtest/gtest.h"
Expand Down Expand Up @@ -379,6 +380,14 @@ TEST_P(
.starts_with(partition_prefix));
}

TEST(RemotePathProviderTest, TestTopicMountManifestPath) {
remote_path_provider path_provider(test_label, std::nullopt);
topic_mount_manifest manifest(test_label, test_tp_ns);
EXPECT_STREQ(
path_provider.topic_mount_manifest_path(manifest).c_str(),
"migration/deadbeef-0000-0000-0000-000000000000/kafka/tp");
}

INSTANTIATE_TEST_SUITE_P(
LabeledWithOverride,
OverrideParamRemotePathProviderWithLabelTest,
Expand Down
Loading

0 comments on commit 45b4cc1

Please sign in to comment.