junrao commented on code in PR #16443: URL: https://github.com/apache/kafka/pull/16443#discussion_r1777730079
########## metadata/src/main/java/org/apache/kafka/controller/FeatureControlManager.java: ########## @@ -172,14 +173,25 @@ private FeatureControlManager( ControllerResult<Map<String, ApiError>> updateFeatures( Map<String, Short> updates, Map<String, FeatureUpdate.UpgradeType> upgradeTypes, - boolean validateOnly + boolean validateOnly, + short requestVersion ) { 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); + if (requestVersion > 1 && !error.error().equals(Errors.NONE)) { Review Comment: > Hmm -- 3.9 has kraft and metadata version right? That's true. Here is my reasoning. The old behavior of v1 allows the setting of kraft.version=1 and metadata.version=3.8. However, this is incorrect since kraft.version=1 depends on metadata.version=3.9. So, by failing fast, we are fixing a bug here. Failing fast does mean that we disallow certain old behavior like accepting metadata.version=3.8 and rejecting kraft.version=-1. But the impact is not as important. -- 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