The Wayback Machine - https://web.archive.org/web/20251210162156/https://github.com/apache/kafka/pull/11577
Skip to content

Conversation

@cmccabe
Copy link
Contributor

@cmccabe cmccabe commented Dec 7, 2021

Require that topics exist before topic configurations can be created for them.

Merge the code from ConfigurationControlManager#checkConfigResource into
ControllerConfigurationValidator to avoid duplication.

Add KRaft support to DynamicConfigChangeTest.

Split out tests in DynamicConfigChangeTest that don't require a cluster into
DynamicConfigChangeUnitTest to save test time.

Require that topics exist before topic configurations can be created for them.

Merge the code from ConfigurationControlManager#checkConfigResource into
ControllerConfigurationValidator to avoid duplication.

Add KRaft support to DynamicConfigChangeTest.

Split out tests in DynamicConfigChangeTest that don't require a cluster into
DynamicConfigChangeUnitTest to save test time.
Copy link
Member

@mumrah mumrah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this clean up @cmccabe. I was looking at the topic config validation in ConfigurationControlManager just this week and wondered if it belonged elsewhere :)

Just a few minor questions inline.

}
}

class ConfigResourceExistenceChecker implements Consumer<ConfigResource> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a comment that this thing should only be called by the event queue thread.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it might be nicer in terms of control flow to return an ApiError instance instead of throwing exceptions. Since these are all unchecked errors, the caller has to know to capture one and convert it to an ApiError

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a comment that this thing should only be called by the event queue thread.

Sounds good, will add.

Also, it might be nicer in terms of control flow to return an ApiError instance instead of throwing exceptions. Since these are all unchecked errors, the caller has to know to capture one and convert it to an ApiError

I did do that for a bunch of other controller code, but over time I've been converting it to use exceptions. The problem is that there are a lot of places where exceptions can be thrown, so you always end up setting up a catch block anyway. If there's no catch block there will inevitably be a bug where something is thrown and not caught.

I wish we were using a language like Rust or Go where exceptions were reserved for logic errors, but it's unfortunately not the case. So, when in Rome...

/**
* A predicate that returns information about whether a ConfigResource exists.
*/
private final ConfigResourceExistenceChecker resourceExists;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe use the less specific type here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

LogConfig.validate(properties)
case BROKER =>
// TODO: add broker configuration validation
if (resource.name().nonEmpty) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we probably have other places where we validate broker IDs from strings. Is there a utility method we can use here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I'm not aware of any. ZkAdminManager just uses Integer.valueOf, as does TopicCommand and KafkaConfig.

Copy link
Member

@mumrah mumrah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good, thanks @cmccabe :shipit:

@cmccabe cmccabe merged commit 454d63c into apache:trunk Dec 10, 2021
@cmccabe cmccabe deleted the KAFKA-13515_kraft_config branch December 10, 2021 20:30
xdgrulez pushed a commit to xdgrulez/kafka that referenced this pull request Dec 22, 2021
Require that topics exist before topic configurations can be created for them.

Merge the code from ConfigurationControlManager#checkConfigResource into
ControllerConfigurationValidator to avoid duplication.

Add KRaft support to DynamicConfigChangeTest.

Split out tests in DynamicConfigChangeTest that don't require a cluster into
DynamicConfigChangeUnitTest to save test time.

Reviewers: David Arthur <mumrah@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants