-
Notifications
You must be signed in to change notification settings - Fork 14.9k
KAFKA-20111: Handle pre-4.1 brokers in kafka-configs.sh for groups #21385
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
Open
AndrewJSchofield
wants to merge
8
commits into
apache:trunk
Choose a base branch
from
AndrewJSchofield:KAFKA-20111
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+104
−6
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7bcc130
KAFKA-20111: Handle pre-4.1 brokers in kafka-configs.sh for groups
AndrewJSchofield 1685a80
Add test and fix exception handling
AndrewJSchofield c7b5c64
Optional result from listing resources
AndrewJSchofield cb54832
Improve checking
AndrewJSchofield c9029ee
Assertion in test
AndrewJSchofield d917d47
Review comments
AndrewJSchofield 4dae579
Review comments
AndrewJSchofield 51fc2e9
Handle ClusterAuthorizationException
AndrewJSchofield File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,10 +33,14 @@ | |
| import org.apache.kafka.clients.admin.DescribeConfigsResult; | ||
| import org.apache.kafka.clients.admin.DescribeUserScramCredentialsOptions; | ||
| import org.apache.kafka.clients.admin.DescribeUserScramCredentialsResult; | ||
| import org.apache.kafka.clients.admin.ListConfigResourcesOptions; | ||
| import org.apache.kafka.clients.admin.ListConfigResourcesResult; | ||
| import org.apache.kafka.clients.admin.MockAdminClient; | ||
| import org.apache.kafka.common.Node; | ||
| import org.apache.kafka.common.config.ConfigResource; | ||
| import org.apache.kafka.common.errors.ClusterAuthorizationException; | ||
| import org.apache.kafka.common.errors.InvalidConfigurationException; | ||
| import org.apache.kafka.common.errors.UnsupportedVersionException; | ||
| import org.apache.kafka.common.internals.KafkaFutureImpl; | ||
| import org.apache.kafka.common.quota.ClientQuotaAlteration; | ||
| import org.apache.kafka.common.quota.ClientQuotaEntity; | ||
|
|
@@ -1413,6 +1417,87 @@ public void shouldNotAlterGroupConfigWithoutEntityName() { | |
| assertEquals("An entity name must be specified with --alter of groups", exception.getMessage()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testDescribeGroupConfigOldBroker() { | ||
| ConfigCommand.ConfigCommandOptions describeOpts = new ConfigCommand.ConfigCommandOptions(toArray("--bootstrap-server", "localhost:9092", | ||
| "--entity-type", "groups", | ||
| "--describe")); | ||
|
|
||
| KafkaFutureImpl<Collection<ConfigResource>> future = new KafkaFutureImpl<>(); | ||
| ListConfigResourcesResult listConfigResourcesResult = mock(ListConfigResourcesResult.class); | ||
| when(listConfigResourcesResult.all()).thenReturn(future); | ||
|
|
||
| AtomicBoolean listedConfigResources = new AtomicBoolean(false); | ||
| Node node = new Node(1, "localhost", 9092); | ||
| MockAdminClient mockAdminClient = new MockAdminClient(List.of(node), node) { | ||
| @Override | ||
| public ListConfigResourcesResult listConfigResources(Set<ConfigResource.Type> configResourceTypes, ListConfigResourcesOptions options) { | ||
| ConfigResource.Type type = configResourceTypes.iterator().next(); | ||
| assertEquals(ConfigResource.Type.GROUP, type); | ||
| future.completeExceptionally(new UnsupportedVersionException("The v0 ListConfigResources only supports CLIENT_METRICS")); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add a test case for other exceptions to ensure they are propagated correctly and not swallowed
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| listedConfigResources.set(true); | ||
| return listConfigResourcesResult; | ||
| } | ||
| }; | ||
|
|
||
| ConfigCommand.describeConfig(mockAdminClient, describeOpts); | ||
| assertTrue(listedConfigResources.get()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testDescribeGroupConfigOldBrokerNotAuthorized() { | ||
| ConfigCommand.ConfigCommandOptions describeOpts = new ConfigCommand.ConfigCommandOptions(toArray("--bootstrap-server", "localhost:9092", | ||
| "--entity-type", "groups", | ||
| "--describe")); | ||
|
|
||
| KafkaFutureImpl<Collection<ConfigResource>> future = new KafkaFutureImpl<>(); | ||
| ListConfigResourcesResult listConfigResourcesResult = mock(ListConfigResourcesResult.class); | ||
| when(listConfigResourcesResult.all()).thenReturn(future); | ||
|
|
||
| AtomicBoolean listedConfigResources = new AtomicBoolean(false); | ||
| Node node = new Node(1, "localhost", 9092); | ||
| MockAdminClient mockAdminClient = new MockAdminClient(List.of(node), node) { | ||
| @Override | ||
| public ListConfigResourcesResult listConfigResources(Set<ConfigResource.Type> configResourceTypes, ListConfigResourcesOptions options) { | ||
| ConfigResource.Type type = configResourceTypes.iterator().next(); | ||
| assertEquals(ConfigResource.Type.GROUP, type); | ||
| future.completeExceptionally(new ClusterAuthorizationException("Not authorized to the cluster")); | ||
| listedConfigResources.set(true); | ||
| return listConfigResourcesResult; | ||
| } | ||
| }; | ||
|
|
||
| ConfigCommand.describeConfig(mockAdminClient, describeOpts); | ||
| assertTrue(listedConfigResources.get()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testDescribeGroupConfigOldBrokerUnexpectedException() { | ||
| ConfigCommand.ConfigCommandOptions describeOpts = new ConfigCommand.ConfigCommandOptions(toArray("--bootstrap-server", "localhost:9092", | ||
| "--entity-type", "groups", | ||
| "--describe")); | ||
|
|
||
| KafkaFutureImpl<Collection<ConfigResource>> future = new KafkaFutureImpl<>(); | ||
| ListConfigResourcesResult listConfigResourcesResult = mock(ListConfigResourcesResult.class); | ||
| when(listConfigResourcesResult.all()).thenReturn(future); | ||
|
|
||
| AtomicBoolean listedConfigResources = new AtomicBoolean(false); | ||
| Node node = new Node(1, "localhost", 9092); | ||
| MockAdminClient mockAdminClient = new MockAdminClient(List.of(node), node) { | ||
| @Override | ||
| public ListConfigResourcesResult listConfigResources(Set<ConfigResource.Type> configResourceTypes, ListConfigResourcesOptions options) { | ||
| ConfigResource.Type type = configResourceTypes.iterator().next(); | ||
| assertEquals(ConfigResource.Type.GROUP, type); | ||
| future.completeExceptionally(new InvalidConfigurationException("That was unexpected")); | ||
| listedConfigResources.set(true); | ||
| return listConfigResourcesResult; | ||
| } | ||
| }; | ||
|
|
||
| assertThrows(InvalidConfigurationException.class, () -> ConfigCommand.describeConfig(mockAdminClient, describeOpts)); | ||
| assertTrue(listedConfigResources.get()); | ||
| } | ||
|
|
||
| public static String[] toArray(String... first) { | ||
| return first; | ||
| } | ||
|
|
@@ -1462,6 +1547,11 @@ public DescribeClientQuotasResult describeClientQuotas(ClientQuotaFilter filter, | |
| public AlterClientQuotasResult alterClientQuotas(Collection<ClientQuotaAlteration> entries, AlterClientQuotasOptions options) { | ||
| return mock(AlterClientQuotasResult.class); | ||
| } | ||
|
|
||
| @Override | ||
| public ListConfigResourcesResult listConfigResources(Set<ConfigResource.Type> configResourceTypes, ListConfigResourcesOptions options) { | ||
| return mock(ListConfigResourcesResult.class); | ||
| } | ||
| } | ||
|
|
||
| private <T> Seq<T> seq(Collection<T> seq) { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
@AndrewJSchofield are you happy with this comment ? 😄
the latest commit d917d47 seems to not handle this comment
Uh oh!
There was an error while loading. Please reload this page.
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 used slightly different words for the comment text. But, I see. I didn't quite get the second part of this. I'll take a look a bit later today.