junrao commented on code in PR #16443:
URL: https://github.com/apache/kafka/pull/16443#discussion_r1775782571


##########
metadata/src/main/java/org/apache/kafka/controller/FeatureControlManager.java:
##########
@@ -174,15 +175,27 @@ ControllerResult<Map<String, ApiError>> updateFeatures(
         Map<String, FeatureUpdate.UpgradeType> upgradeTypes,
         boolean validateOnly
     ) {
+        boolean updateFailed = false;
         TreeMap<String, ApiError> results = new TreeMap<>();
         List<ApiMessageAndVersion> records =
                 BoundedList.newArrayBacked(MAX_RECORDS_PER_USER_OP);
+
+        Map<String, Short> proposedUpdatedVersions = new HashMap<>();
+        finalizedVersions.forEach(proposedUpdatedVersions::put);
+        proposedUpdatedVersions.put(MetadataVersion.FEATURE_NAME, 
metadataVersion.get().featureLevel());
+        updates.forEach(proposedUpdatedVersions::put);
+
         for (Entry<String, Short> entry : updates.entrySet()) {
-            results.put(entry.getKey(), updateFeature(entry.getKey(), 
entry.getValue(),
-                upgradeTypes.getOrDefault(entry.getKey(), 
FeatureUpdate.UpgradeType.UPGRADE), records));
+            ApiError error = updateFeature(entry.getKey(), entry.getValue(),
+                upgradeTypes.getOrDefault(entry.getKey(), 
FeatureUpdate.UpgradeType.UPGRADE), records, proposedUpdatedVersions);
+            results.put(entry.getKey(), error);
+            if (!error.error().equals(Errors.NONE)) {
+                updateFailed = true;
+                break;
+            }
         }
 
-        if (validateOnly) {
+        if (validateOnly || updateFailed) {

Review Comment:
   I was thinking of just having the following schema. We can return the cause 
in the top level error message.
   
   ```
   {
     "apiKey": 57,
     "type": "response",
     "name": "UpdateFeaturesResponse",
     "validVersions": "0-1",
     "flexibleVersions": "0+",
     "fields": [
       { "name": "ThrottleTimeMs", "type": "int32", "versions": "0+",
         "about": "The duration in milliseconds for which the request was 
throttled due to a quota violation, or zero if the request did not violate any 
quota." },
       { "name": "ErrorCode", "type": "int16", "versions": "0+",
         "about": "The top-level error code, or `0` if there was no top-level 
error." },
       { "name": "ErrorMessage", "type": "string", "versions": "0+", 
"nullableVersions": "0+",
         "about": "The top-level error message, or `null` if there was no 
top-level error." }
     ]
   }
   ```
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to