Skip to content
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

[KIP-430] DescribeConsumerGroups, DescribeTopics, DescribeCluster with authorized AclOperations #2021

Merged
merged 18 commits into from
Oct 18, 2023

Conversation

jainruchir
Copy link
Contributor

No description provided.

@cla-assistant
Copy link

cla-assistant bot commented Aug 7, 2023

CLA assistant check
All committers have signed the CLA.

@emasab emasab changed the title kip430: describe CSG/topics/cluster with authorized AclOperations [KIP-430] DescribeConsumerGroups, DescribeTopics, DescribeCluster with authorized AclOperations Sep 7, 2023
@emasab emasab marked this pull request as ready for review September 13, 2023 18:23
@emasab emasab requested a review from milindl September 13, 2023 18:23
Copy link
Contributor

@milindl milindl left a comment

Choose a reason for hiding this comment

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

Seems mostly okay, some minor changes and comments

node?.ToString() ?? "null"
).ToList());
var authorizedOperations = string.Join(",",
AuthorizedOperations.Select(authorizedOperation =>
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose AuthorizedOperations can be null, too, right?

needs handling for that

).ToList();
}

private unsafe List<AclOperation> extractAuthorizedOperations(IntPtr authorizedOperationsPtr, int authorizedOperationCount)
Copy link
Contributor

Choose a reason for hiding this comment

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

authorizedOperationsPtr maybe a null pointer, and in that case we should return null, rather than an empty list, what do you think?

/// <summary>
/// Extension methods for default <see cref="IAdminClient"/> implementations.
/// </summary>
public static class IAdminClientExtensions
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: why are we using IAdminClientExtensions, and not using IAdminClient?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see we are doing this to avoid breaking binary compatibility but we don't guarantee that for .NET, right?
Also, as per https://learn.microsoft.com/en-us/dotnet/core/compatibility/categories#binary-compatibility
If we just add methods or method implementations, that doesn't break binary compatibility, too, right?

Copy link
Contributor

@emasab emasab Sep 26, 2023

Choose a reason for hiding this comment

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

Yeah, it's extending an interface that breaks it, in case one has it implemented. We're starting to avoid breaking it.

foreach (var partition in topic.Partitions)
{
Console.WriteLine($" Partition ID: {partition.Partition} with leader: {partition.Leader}");
if(!partition.ISR.Any()){
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: stick to the formatting norms of the brace on next line, here and elsewhere in this file

Members.Select(member =>
member.ToString()
).ToList());
var authorizedOperations = string.Join(",",
Copy link
Contributor

Choose a reason for hiding this comment

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

Add handling for if AuthorizedOperations is null

Assert.Equal(2, resCount);

// TODO: remove after fix
ex.Results.TopicDescriptions.Sort(
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: can remove now

Assert.Empty(ex.Results.TopicDescriptions[0].AuthorizedOperations);
Assert.Empty(ex.Results.TopicDescriptions[1].AuthorizedOperations);
Assert.True(ex.Results.TopicDescriptions[0].Error.IsError);
Assert.True(!ex.Results.TopicDescriptions[1].Error.IsError);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: use Assert.False instead.


var descResAuthOps =
descResWithAuthOps.TopicDescriptions[0].AuthorizedOperations;
Assert.Equal(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should OrderBy before asserting equality, because while the order of the operations will be exactly what you described, there is no reason for it to be so (and it's not something we or the user should assume)
Here and elsewhere

Copy link
Contributor

Choose a reason for hiding this comment

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

The order will be that one because it comes from the order in the enum that corresponds to the bitfield order too

topicList.IndexOf(b.Name);
}
);
Assert.Empty(ex.Results.TopicDescriptions[0].AuthorizedOperations);
Copy link
Contributor

Choose a reason for hiding this comment

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

Note to change this to asserting null after making change to allow for null authorized operations
here and in other files

},
Entry = new AccessControlEntry
{
Principal = "User:user",
Copy link
Contributor

Choose a reason for hiding this comment

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

Use
"User:(value of string user)"
rather than hard-coding it.
For all the relevant tests.

Copy link
Contributor

@milindl milindl 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 looking into this @emasab !
Approved with a few comments here and there.

{
Console.WriteLine(" There is no In-Sync-Replica broker for the partition");
}
else{
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
else{
else
{

{
Console.WriteLine(" There is no Replica broker for the partition");
}
else{
Copy link
Contributor

Choose a reason for hiding this comment

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

these are nits but

Suggested change
else{
else
{


}
Console.WriteLine($" Is internal: {topic.IsInternal}");
if(includeAuthorizedOperations)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if(includeAuthorizedOperations)
if (includeAuthorizedOperations)

},
Entry = new AccessControlEntry
{
Principal = "User:user",
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe, this comment was missed for this test : #2021 (comment)
We should pick this dynamically

@emasab emasab merged commit 58b5291 into master Oct 18, 2023
1 of 2 checks passed
@emasab emasab deleted the dev_kip430 branch October 18, 2023 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants