-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
KAFKA-18629: ShareGroupDeleteState admin client impl. #18928
Conversation
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.
Thanks for the PR.
I think the testing is a bit light. For example, --delete --all-topics
where there is 0, 1 or multiple groups. That kind of thing.
List<String> groupIds = opts.options.has(opts.allGroupsOpt) | ||
? listShareGroups() | ||
: opts.options.valuesOf(opts.groupOpt); | ||
|
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.
Because deleteShareGroups
actually deletes all types of group, I think it would be prudent for this method to check that the groups being deleted are share groups.
In the --all-groups
case, you're listing the share groups. If you listed the share groups in the other case too, you'd easily be able to see whether the groups are share groups and then avoid deleting consumer groups unawares. Do you think this would be a sensible precaution? It's quite a limited code change.
String secondGroup = "second-group"; | ||
String bootstrapServer = "localhost:9092"; | ||
|
||
String[] cgcArgs = new String[]{"--bootstrap-server", bootstrapServer, "--delete"}; |
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 would have expected the command line parsing to fail because cgcArgs
doesn't include either --group
or --all-groups
. Similar comment for the other tests.
DeleteShareGroupsResult(final Map<String, KafkaFuture<Void>> futures) { | ||
super(futures); | ||
} | ||
} |
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 implementation for the public methods here could be added.
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.
As of now, it is exactly the same as the parent class.
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.
Yes, OK. I suggest making a common superclass DeleteGroupsResult
and having both DeleteConsumerGroupsResult
and DeleteShareGroupsResult
inheriting from that.
--all-topics is not related to delete group call. Is it? |
Sorry! I meant |
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.
Thanks for the changes. A few more comments.
@@ -953,6 +953,14 @@ default ListConsumerGroupOffsetsResult listConsumerGroupOffsets(Map<String, List | |||
*/ | |||
DeleteConsumerGroupsResult deleteConsumerGroups(Collection<String> groupIds, DeleteConsumerGroupsOptions options); | |||
|
|||
/** |
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.
Personally, I'd prefer to see these two methods declared with the other share group methods, not mixed in with the consumer group methods.
DeleteShareGroupsResult(final Map<String, KafkaFuture<Void>> futures) { | ||
super(futures); | ||
} | ||
} |
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.
Yes, OK. I suggest making a common superclass DeleteGroupsResult
and having both DeleteConsumerGroupsResult
and DeleteShareGroupsResult
inheriting from that.
|
||
import org.apache.kafka.common.utils.LogContext; | ||
|
||
public class DeleteShareGroupsHandler extends DeleteConsumerGroupsHandler { |
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.
Again, in a similar vein, maybe having a common DeleteGroupsHandler
and having 2 subclasses would be sensible here. Having the share group handler inherit from the consumer group one is strange. I'm pretty sure that there will be an Admin.deleteGroups
method before long too.
: opts.options.valuesOf(opts.groupOpt); | ||
|
||
if (groupIds.isEmpty()) { | ||
throw new IllegalArgumentException("--groups or --all-groups argument is mandatory"); |
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 would have said that the checking that there is either --groups
or --all-groups
should be done in the command line validation, not here.
As it stands, if the user specified --all-groups
and there are no share groups, the error message is --groups or --all-groups is mandatory
. Really, I would have said that this should be treated as successful deletion of no groups. That's what kafka-consumer-groups.sh
does. It says "Deletion of requested share groups ('') was successful." Slight inelegant, but effective.
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
It is already happening correctly. The util method getShareGroupService
was not performing the validation check and hence I missed it and added it at the wrong place.
I will rectify.
System.out.println("Deletion of requested share groups (" + "'" + success.keySet().stream().map(Object::toString).collect(Collectors.joining(", ")) + "'" + ") was successful."); | ||
else { | ||
printError("Deletion of some share groups failed:", Optional.empty()); | ||
failed.forEach((group, error) -> System.out.println("* Share Group '" + group + "' could not be deleted due to: " + error)); |
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.
nit: Share group
not Share Group
please.
@AndrewJSchofield Thanks for the review |
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.
Looking good now, with just one more area for improvement.
The output of the kafka-share-groups.sh --delete
command in error cases is a bit untidy. Some examples:
bin/kafka-share-groups.sh --bootstrap-server localhost:9092 --delete --group SG1
when the group is not empty, the exception stack trace is printed. The equivalent for bin/kafka-consumer-groups.sh
is much neater.
bin/kafka-share-groups.sh --bootstrap-server localhost:9092 --delete --group CG1
where CG1 is a consumer group prints an error message, and then prints the command usage message which is massive. Ideally, it would just say something like:
* Group 'CG1' could not be deleted due to: java.lang.IllegalStateException: Group CG1 is not a share group.
or something like that.
@AndrewJSchofield Thanks for the review, incorporated comments.
|
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.
Thanks for the updates. Looks good to me.
deleteShareGroups
functionality via thekafka-share-groups.sh
script.