@@ -75,6 +75,20 @@ errc map_errc(std::error_code ec) {
7575 }
7676 return errc::rpc_error;
7777}
78+
79+ bool is_topic_mutable (::cluster_link::model::mirror_topic_status status) {
80+ switch (status) {
81+ case ::cluster_link::model::mirror_topic_status::active:
82+ case ::cluster_link::model::mirror_topic_status::failed:
83+ case ::cluster_link::model::mirror_topic_status::paused:
84+ case ::cluster_link::model::mirror_topic_status::failing_over:
85+ case ::cluster_link::model::mirror_topic_status::promoting:
86+ return false ;
87+ case ::cluster_link::model::mirror_topic_status::failed_over:
88+ case ::cluster_link::model::mirror_topic_status::promoted:
89+ return true ;
90+ }
91+ }
7892} // namespace
7993
8094frontend::frontend (
@@ -211,17 +225,7 @@ bool frontend::is_topic_mutable_for_kafka_api(const model::topic& topic) const {
211225 // topic does not belong to any cluster link
212226 return true ;
213227 }
214- switch (*status) {
215- case ::cluster_link::model::mirror_topic_status::active:
216- case ::cluster_link::model::mirror_topic_status::failed:
217- case ::cluster_link::model::mirror_topic_status::paused:
218- case ::cluster_link::model::mirror_topic_status::failing_over:
219- case ::cluster_link::model::mirror_topic_status::promoting:
220- return false ;
221- case ::cluster_link::model::mirror_topic_status::failed_over:
222- case ::cluster_link::model::mirror_topic_status::promoted:
223- return true ;
224- }
228+ return is_topic_mutable (*status);
225229}
226230
227231std::optional<chunked_hash_map<
@@ -310,8 +314,16 @@ bool frontend::schema_registry_shadowing_active() const {
310314 if (!md.has_value ()) {
311315 return false ;
312316 }
313- // If mirror_schema_registry_topic option is set, then shadowing for
314- // SR is active
317+ // Check to see if the schema registry topic is in the mirror topic list
318+ const auto & mirror_topics = md->get ().state .mirror_topics ;
319+ auto topic_it = mirror_topics.find (
320+ ::model::schema_registry_internal_tp.topic );
321+ if (topic_it != mirror_topics.end ()) {
322+ // If it is, return whether or not it is mutable based on its status
323+ return !is_topic_mutable (topic_it->second .status );
324+ }
325+ // If mirror_schema_registry_topic option is set and the topic is not
326+ // yet in the mirror topic list, then shadowing for SR is active
315327 const auto & sr_cfg = md->get ().configuration .schema_registry_sync_cfg ;
316328 if (
317329 sr_cfg.sync_schema_registry_topic_mode .has_value ()
@@ -322,10 +334,7 @@ bool frontend::schema_registry_shadowing_active() const {
322334 return true ;
323335 }
324336
325- // If the schema registry topic is in the mirror_topics list, then
326- // disable writes
327- return md->get ().state .mirror_topics .contains (
328- ::model::schema_registry_internal_tp.topic );
337+ return false ;
329338 });
330339}
331340
0 commit comments