Open vikramsubramanian opened 1 month ago
To address the issue where the acl_ssl
entry disappears when ordering ACLs by "Team," follow these actionable steps:
mergeReduceAcls
method to ensure acl_ssl
entries are correctly combined and displayed.sortAclInfo
method correctly handles the acl_ssl
field when grouping by team.mergeReduceAcls
method in BaseOverviewService.java
:private List<AclOverviewInfo> mergeReduceAcls(List<AclOverviewInfo> aclInfo) {
AclOverviewInfo producerIp = null, producerPrincipal = null;
AclOverviewInfo consumerIp = null, consumerPrincipal = null;
for (AclOverviewInfo info : aclInfo) {
if (info.getTopictype().equals(AclType.PRODUCER.value)) {
if (info.getAcl_ip() != null && !info.getAcl_ip().isEmpty()) {
producerIp = initializeAclInfo(producerIp, info);
producerIp.getAcl_ips().add(info.getAcl_ip());
} else if (info.getAcl_ssl() != null && !info.getAcl_ssl().isEmpty()) {
producerPrincipal = initializeAclInfo(producerPrincipal, info);
producerPrincipal.getAcl_ssls().add(info.getAcl_ssl());
}
} else if (info.getTopictype().equals(AclType.CONSUMER.value)) {
if (info.getAcl_ip() != null && !info.getAcl_ip().isEmpty()) {
consumerIp = initializeAclInfo(consumerIp, info);
consumerIp.getAcl_ips().add(info.getAcl_ip());
} else if (info.getAcl_ssl() != null && !info.getAcl_ssl().isEmpty()) {
consumerPrincipal = initializeAclInfo(consumerPrincipal, info);
consumerPrincipal.getAcl_ssls().add(info.getAcl_ssl());
}
}
}
return addToListIfNotNull(producerIp, producerPrincipal, consumerIp, consumerPrincipal);
}
private List<AclOverviewInfo> addToListIfNotNull(
AclOverviewInfo producerIp,
AclOverviewInfo producerPrincipal,
AclOverviewInfo consumerIp,
AclOverviewInfo consumerPrincipal) {
List<AclOverviewInfo> buildList = new ArrayList<>();
if (producerIp != null) {
buildList.add(producerIp);
}
if (consumerIp != null) {
buildList.add(consumerIp);
}
if (producerPrincipal != null) {
buildList.add(producerPrincipal);
}
if (consumerPrincipal != null) {
buildList.add(consumerPrincipal);
}
return buildList;
}
private AclOverviewInfo initializeAclInfo(AclOverviewInfo newAcl, AclOverviewInfo info) {
if (newAcl == null) {
newAcl = new AclOverviewInfo();
copyProperties(info, newAcl);
newAcl.setAcl_ips(new HashSet<>());
newAcl.setAcl_ssls(new HashSet<>());
// remove old information from the copy properties that is no longer needed to avoid confusion.
newAcl.setAcl_ip(null);
newAcl.setAcl_ssl(null);
}
return newAcl;
}
sortAclInfo
method in BaseOverviewService.java
:private List<AclOverviewInfo> sortAclInfo(List<AclOverviewInfo> aclInfo, AclGroupBy groupBy) {
// merge reduce
if (groupBy.equals(AclGroupBy.TEAM)) {
aclInfo = mergeReduceAclInfo(aclInfo);
aclInfo.sort(
Comparator.comparing(AclOverviewInfo::getTeamname, nullSafeStringComparator)
.thenComparing(AclOverviewInfo::getConsumergroup, nullSafeStringComparator));
}
return aclInfo;
}
By ensuring the acl_ssl
field is correctly aggregated and handled in the merging and sorting methods, the principal/username information should be correctly displayed when grouping ACLs by team.
💡 To rerun Mayil, comment mayil-ai rerun
. Mayil will incorporate any new context added to the ticket. Include details in your rerun comment to guide Mayil!
What happened?
I created an ACL for a standard kafka env and when I tried to order by "Team" the principal/username entry disapeared.
What did you expect to happen?
Rest Call /getTopicOverview?environmentId=2&groupBy=NONE&topicName=Release250 response { "topicExists": true, "schemaExists": false, "prefixAclsExists": false, "txnAclsExists": false, "createSchemaAllowed": false, "topicInfoList": ...... "aclInfoList": [ { "req_no": "1048", "aclPatternType": "LITERAL", "environment": "2", "environmentName": "TST", "kafkaFlavorType": "APACHE_KAFKA", "showDeleteAcl": true, "teamid": 1005, "teamname": "ralph", "topicname": "Release250", "topictype": "Producer", "acl_ip": "127.0.0.1", "acl_ssl": "User:" }, { "req_no": "1049", "aclPatternType": "LITERAL", "environment": "2", "environmentName": "TST", "kafkaFlavorType": "APACHE_KAFKA", "showDeleteAcl": true, "teamid": 1005, "teamname": "ralph", "topicname": "Release250", "topictype": "Consumer", "acl_ip": "127.0.0.1", "acl_ssl": "User:", "consumergroup": "releaseOne" } ], ......
returned json
Rest Call
response { "topicExists": true, "schemaExists": false, "prefixAclsExists": false, "txnAclsExists": false, "createSchemaAllowed": false, "topicInfoList": ....... "aclInfoList": [ { "req_no": "1049", "aclPatternType": "LITERAL", "environment": "2", "environmentName": "TST", "kafkaFlavorType": "APACHE_KAFKA", "showDeleteAcl": true, "teamid": 1005, "teamname": "ralph", "topicname": "Release250", "topictype": "Consumer", "acl_ips": [ "127.0.0.1" ], "acl_ssls": [], "consumergroup": "releaseOne" }, { "req_no": "1048", "aclPatternType": "LITERAL", "environment": "2", "environmentName": "TST", "kafkaFlavorType": "APACHE_KAFKA", "showDeleteAcl": true, "teamid": 1005, "teamname": "ralph", "topicname": "Release250", "topictype": "Producer", "acl_ips": [ "127.0.0.1" ], "acl_ssls": [] } ],
The principals should be combined and entries shown in one row item based on team and if it is a producer or consumer. The aclSSL array should have returned "acl_ssl": ["User:*"],