-
Notifications
You must be signed in to change notification settings - Fork 14.9k
KAFKA-19931 Align broker and controller behavior for the Admin.incrementalAlterConfigs API #21005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
chia7712
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@m1a2st could you take a look at the failed test testInvalidIncrementalAlterConfigsResources?
junrao
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@m1a2st : Thanks for the PR. Left a comment.
| altersByName.put(config.name, new util.AbstractMap.SimpleEntry[AlterConfigOp.OpType, String]( | ||
| AlterConfigOp.OpType.forId(config.configOperation), config.value)) | ||
| if (!nullUpdates.isEmpty) { | ||
| throw new InvalidRequestException("Null value not supported for : " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to just set the error response here instead of throwing?
| } catch { | ||
| case t: Throwable => ApiError.fromThrowable(t) | ||
| try { | ||
| val nullUpdates = new util.ArrayList[String]() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, there are quite a few pre-processing checks in ConfigAdminManager. The doc says the following. Could we restructure the code between ConfigAdminManager and ControllerApis to (1) avoid duplicates logic in verification (2) prevent missing verification in one of the two places in the future?
// BROKER_LOGGER requests always go to a specific, constant broker or controller node.
//
// BROKER resource changes for a specific (non-default) resource go to either that specific
// node (if using bootstrap.servers), or directly to the active controller (if using
// bootstrap.controllers)
//
// All other requests go to the least loaded broker (if using bootstrap.servers) or the
// active controller (if using bootstrap.controllers)
| resource) | ||
| ApiError.NONE | ||
| } catch { | ||
| case t: Throwable => ApiError.fromThrowable(t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not throwing the exception directly? The onError method should handle it, right?
| setResourceType(ConfigResource.Type.BROKER.id()), | ||
| new AlterConfigsResourceResponse(). | ||
| setErrorCode(UNSUPPORTED_VERSION.code()). | ||
| setErrorCode(INVALID_REQUEST.code()). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The controller error code should match the broker error code.
chia7712
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@m1a2st would you mind updating the upgrade.html to inform users about this behaviour change?
| configChanges: util.HashMap[ConfigResource, util.Map[String, Entry[AlterConfigOp.OpType, String]]], | ||
| response: IncrementalAlterConfigsResponseData | ||
| ): Unit = { | ||
| if (!duplicateResources.contains(configResource)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use configChanges instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant that the configChanges collection could be used to check the duplicates, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old logic worked in three steps:
- The first occurrence of a configResource is added to the map.
- The second occurrence of the same configResource is removed from the map, added to duplicateValue, and written to the response.
- The third and any subsequent occurrences of that configResource are ignored entirely.
Given this behavior, I think we cannot rely solely on a map to implement this logic.
|
@m1a2st I noticed another inconsistent behavior. The following code fails on the broker but succeeds on the controller. admin.incrementalAlterConfigs(Map.of(
new ConfigResource(ConfigResource.Type.TOPIC, "chia"),
List.of(new AlterConfigOp(new ConfigEntry("cleanup.policy", "compact"), OpType.SET),
new AlterConfigOp(new ConfigEntry("cleanup.policy", "compact"), OpType.SET),
new AlterConfigOp(new ConfigEntry("flush.ms", "11000"), OpType.SET))
) |
It appears this behaviour gets fixed also. @m1a2st would you mind updating the PR description and add the integration test ? |
junrao
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@m1a2st : Thanks for the PR. Since this is a behavior change, it's probably better to do a KIP so that more people are aware of it.
|
Thanks for @junrao comment, I have started a discussion thread. FYI: https://lists.apache.org/thread/lqn0xw0zdfwl9m990otjvswzqh5bmy8v |
|
@m1a2st I noticed another inconsistency related to this patch. The controller does not validate the dynamic configurations when handling requests, which results in a misleading success response. By contrast, the broker checks the dynamic configurations immediately upon receiving the request, allowing users to catch invalid requests early. Would you mind fixing this as well? |
# Conflicts: # docs/upgrade.html
I also added this inconsistent behavior to the KIP, and I can align it as well. |
This PR updates the behavior of Admin.incrementalAlterConfigs() to be
consistent when invoked using bootstrap servers versus bootstrap
controllers. The following changes apply specifically when using a
bootstrap controller:
Null Config Values (DELETE Only)
A null config value is allowed only when used with
AlterConfigOp.OpType.DELETE.
Supplying null with any other operation type will now result in an
InvalidRequestException.
Duplicate Config Names
Providing duplicate configuration names within the same resource will
now fail with an InvalidRequestException.
Unknown Resource Types
Requests containing unknown resource types will now fail with an
InvalidRequestException.
These changes ensure the controller-based Admin API behaves consistently
and predictably, aligning with broker-side validation rules.
FYI: #20960