Skip to content

Commit 61d6bee

Browse files
committed
return just DLS stats
1 parent 06f3f98 commit 61d6bee

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/stats/TransportSecurityStatsAction.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77
package org.elasticsearch.xpack.security.action.stats;
88

9-
import org.elasticsearch.action.ActionListener;
109
import org.elasticsearch.action.FailedNodeException;
1110
import org.elasticsearch.action.support.ActionFilters;
1211
import org.elasticsearch.action.support.nodes.TransportNodesAction;
@@ -27,8 +26,6 @@
2726

2827
import java.io.IOException;
2928
import java.util.List;
30-
import java.util.Map;
31-
import java.util.concurrent.CompletableFuture;
3229

3330
public class TransportSecurityStatsAction extends TransportNodesAction<
3431
GetSecurityStatsNodesRequest,
@@ -80,12 +77,9 @@ protected GetSecurityStatsNodeResponse newNodeResponse(final StreamInput in, fin
8077

8178
@Override
8279
protected GetSecurityStatsNodeResponse nodeOperation(final GetSecurityStatsNodeRequest request, final Task task) {
83-
final CompletableFuture<Map<String, Object>> rolesStatsFuture = new CompletableFuture<>();
84-
if (rolesStore == null) {
85-
rolesStatsFuture.complete(null);
86-
} else {
87-
rolesStore.usageStats(ActionListener.wrap(rolesStatsFuture::complete, rolesStatsFuture::completeExceptionally));
88-
}
89-
return new GetSecurityStatsNodeResponse(clusterService.localNode(), rolesStatsFuture.join());
80+
return new GetSecurityStatsNodeResponse(
81+
clusterService.localNode(),
82+
rolesStore == null ? null : rolesStore.usageStatsWithJustDls()
83+
);
9084
}
9185
}

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStore.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,10 @@ Iterable<ProjectScoped<RoleKey>> cachedRoles() {
669669
return this.roleCache.keys();
670670
}
671671

672+
public Map<String, Object> usageStatsWithJustDls() {
673+
return Map.of("dls", Map.of("bit_set_cache", dlsBitsetCache.usageStats()));
674+
}
675+
672676
public void usageStats(ActionListener<Map<String, Object>> listener) {
673677
final Map<String, Object> usage = new HashMap<>();
674678
usage.put("dls", Map.of("bit_set_cache", dlsBitsetCache.usageStats()));

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/security/stats/20_roles_stats.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
"Security stats return roles stats":
2+
"Security stats return just DLS stats":
33
- requires:
44
cluster_features: [ "security_stats_endpoint" ]
55
reason: Introduced in 9.2
@@ -9,6 +9,8 @@
99

1010
- set:
1111
nodes._arbitrary_key_: node_id
12+
- length: { nodes.$node_id: 1 }
13+
- length: { nodes.$node_id.roles: 1 }
14+
- length: { nodes.$node_id.roles.dls: 1 }
15+
- length: { nodes.$node_id.roles.dls.bit_set_cache: 8 }
1216
- gte: { nodes.$node_id.roles.dls.bit_set_cache.count: 0 }
13-
- gte: { nodes.$node_id.roles.file.size: 0 }
14-
- gte: { nodes.$node_id.roles.native.size: 0 }

0 commit comments

Comments
 (0)