Skip to content

Commit

Permalink
Merge pull request redpanda-data#23909 from bashtanov/migrations-rena…
Browse files Browse the repository at this point in the history
…me-source-topic-reference

Migrations: rename source topic to source topic reference
  • Loading branch information
bashtanov authored Oct 28, 2024
2 parents fb388a0 + ac506c3 commit 97c11fe
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/v/redpanda/admin/api-doc/migration.def.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"inbound_topic": {
"type": "object",
"properties": {
"source_topic": {
"source_topic_reference": {
"description": "Name of the topic in object storage. To uniquely identify the topic, append the name with /cluster_uuid/initial_revision. ",
"type": "namespaced_topic",
"$ref": "namespaced_topic"
Expand Down
3 changes: 2 additions & 1 deletion src/v/redpanda/admin/data_migration_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ model::topic_namespace parse_topic_namespace(json::Value& json) {

cluster::data_migrations::inbound_topic parse_inbound_topic(json::Value& json) {
cluster::data_migrations::inbound_topic ret;
ret.source_topic_name = parse_topic_namespace(json["source_topic"]);
ret.source_topic_name = parse_topic_namespace(
json["source_topic_reference"]);

// extract location hint from topic name
std::pair<std::string, std::string> split = absl::StrSplit(
Expand Down
9 changes: 3 additions & 6 deletions src/v/redpanda/admin/migrations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ ss::httpd::migration_json::inbound_migration_state to_admin_type(
migration.migration_type = migration_type_enum::inbound;
for (auto& inbound_t : idm.topics) {
ss::httpd::migration_json::inbound_topic inbound_tp;
inbound_tp.source_topic = to_admin_type(
inbound_tp.source_topic_reference = to_admin_type(
inbound_t.source_topic_name, inbound_t.cloud_storage_location);
if (inbound_t.alias) {
inbound_tp.alias = to_admin_type(*inbound_t.alias);
Expand Down Expand Up @@ -205,17 +205,14 @@ json::validator make_migration_validator() {
"inbound_topic": {
"type": "object",
"required": [
"source_topic"
"source_topic_reference"
],
"properties": {
"source_topic": {
"source_topic_reference": {
"$ref": "#/definitions/namespaced_topic"
},
"alias": {
"$ref": "#/definitions/namespaced_topic"
},
"location": {
"type": "string"
}
},
"additionalProperties": false
Expand Down
7 changes: 2 additions & 5 deletions src/v/redpanda/admin/topics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,14 @@ json::validator make_mount_configuration_validator() {
"inbound_topic": {
"type": "object",
"required": [
"source_topic"
"source_topic_reference"
],
"properties": {
"source_topic": {
"source_topic_reference": {
"$ref": "#/definitions/namespaced_topic"
},
"alias": {
"$ref": "#/definitions/namespaced_topic"
},
"location": {
"type": "string"
}
},
"additionalProperties": false
Expand Down
6 changes: 3 additions & 3 deletions tests/rptest/services/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,14 @@ def as_dict(self):

class InboundTopic:
def __init__(self,
src_topic: NamespacedTopic,
source_topic_reference: NamespacedTopic,
alias: NamespacedTopic | None = None):
self.src_topic = src_topic
self.source_topic_reference = source_topic_reference
self.alias = alias

def as_dict(self):
d = {
'source_topic': self.src_topic.as_dict(),
'source_topic_reference': self.source_topic_reference.as_dict(),
}
if self.alias:
d['alias'] = self.alias.as_dict()
Expand Down
7 changes: 4 additions & 3 deletions tests/rptest/tests/data_migrations_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ def test_creating_and_listing_migrations(self):

for t in inbound_topics:
self.logger.info(
f"inbound topic: {self.client().describe_topic(t.src_topic.topic)}"
f"inbound topic: {self.client().describe_topic(t.source_topic_reference.topic)}"
)

self.execute_data_migration_action_flaky(in_migration_id,
Expand Down Expand Up @@ -606,7 +606,7 @@ def test_higher_level_migration_api(self):
for i, t in enumerate(topics[:3])
]
inbound_topics_spec = [
TopicSpec(name=(it.alias or it.src_topic).topic,
TopicSpec(name=(it.alias or it.source_topic_reference).topic,
partition_count=3) for it in inbound_topics
]
reply = self.admin.mount_topics(inbound_topics).json()
Expand Down Expand Up @@ -913,7 +913,8 @@ def test_migrated_topic_data_integrity(self, transfer_leadership: bool,
# two cycles max: to cancel halfway and to complete + check e2e
while not remounted:
in_migration = InboundDataMigration(topics=[
InboundTopic(src_topic=workload_ns_topic, alias=alias)
InboundTopic(source_topic_reference=workload_ns_topic,
alias=alias)
],
consumer_groups=[])
in_migration_id = self.create_and_wait(in_migration)
Expand Down

0 comments on commit 97c11fe

Please sign in to comment.