cmccabe commented on code in PR #16284:
URL: https://github.com/apache/kafka/pull/16284#discussion_r1635406078


##########
metadata/src/main/java/org/apache/kafka/controller/ReplicationControlManager.java:
##########
@@ -2093,6 +2116,50 @@ Optional<ApiMessageAndVersion> 
changePartitionReassignment(TopicIdPartition tp,
         return builder.setDefaultDirProvider(clusterDescriber).build();
     }
 
+    /**
+     * Handle legacy configuration alterations.
+     */
+    ControllerResult<Map<ConfigResource, ApiError>> legacyAlterConfigs(
+            Map<ConfigResource, Map<String, String>> newConfigs) {
+        ControllerResult<Map<ConfigResource, ApiError>> result =
+                configurationControl.legacyAlterConfigs(newConfigs, false);
+        return maybeTriggerUncleanLeaderElection(result);
+    }
+
+    /**
+     * Handle incremental configuration alterations.
+     */
+    ControllerResult<Map<ConfigResource, ApiError>> incrementalAlterConfigs(
+            Map<ConfigResource, Map<String, Entry<OpType, String>>> 
configChanges) {
+        ControllerResult<Map<ConfigResource, ApiError>> result =
+                configurationControl.incrementalAlterConfigs(configChanges, 
false);
+        return maybeTriggerUncleanLeaderElection(result);
+    }
+
+    /**
+     * If "unclean.leader.election.enable" configurations was enabled 
dynamically, generating unclean leader election
+     * records for all the partitions in this topic if necessary.
+     */
+    ControllerResult<Map<ConfigResource, ApiError>> 
maybeTriggerUncleanLeaderElection(
+            ControllerResult<Map<ConfigResource, ApiError>> result) {
+        List<ApiMessageAndVersion> records = new ArrayList<>(result.records());
+        for (ApiMessageAndVersion messageAndVersion : result.records()) {
+            ConfigRecord record = (ConfigRecord) messageAndVersion.message();
+            if (record.name().equals(UNCLEAN_LEADER_ELECTION_ENABLE_CONFIG) && 
"true".equals(record.value())) {
+                String topicName = record.resourceName();

Review Comment:
   This won't work for cases where we're enabling unclean.leader.election for 
the whole node.
   
   For example, if we enable it for the resource `ConfigResource(type=BROKER, 
name="")` then it means that all nodes will turn on unclean leader election by 
default.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to