mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-28 17:34:17 -04:00
Use package to suppress warning for entitlement self-test (#128223)
* Use package to suppress warning for entitlement self-test * [CI] Auto commit changes from spotless --------- Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
This commit is contained in:
parent
14355a79ce
commit
8d79de51f5
4 changed files with 12 additions and 12 deletions
|
@ -43,14 +43,14 @@ public class EntitlementBootstrap {
|
||||||
Function<Class<?>, PolicyManager.PolicyScope> scopeResolver,
|
Function<Class<?>, PolicyManager.PolicyScope> scopeResolver,
|
||||||
PathLookup pathLookup,
|
PathLookup pathLookup,
|
||||||
Map<String, Path> sourcePaths,
|
Map<String, Path> sourcePaths,
|
||||||
Set<Class<?>> suppressFailureLogClasses
|
Set<Package> suppressFailureLogPackages
|
||||||
) {
|
) {
|
||||||
public BootstrapArgs {
|
public BootstrapArgs {
|
||||||
requireNonNull(pluginPolicies);
|
requireNonNull(pluginPolicies);
|
||||||
requireNonNull(scopeResolver);
|
requireNonNull(scopeResolver);
|
||||||
requireNonNull(pathLookup);
|
requireNonNull(pathLookup);
|
||||||
requireNonNull(sourcePaths);
|
requireNonNull(sourcePaths);
|
||||||
requireNonNull(suppressFailureLogClasses);
|
requireNonNull(suppressFailureLogPackages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public class EntitlementBootstrap {
|
||||||
* @param tempDir the temp directory for Elasticsearch
|
* @param tempDir the temp directory for Elasticsearch
|
||||||
* @param logsDir the log directory for Elasticsearch
|
* @param logsDir the log directory for Elasticsearch
|
||||||
* @param pidFile path to a pid file for Elasticsearch, or {@code null} if one was not specified
|
* @param pidFile path to a pid file for Elasticsearch, or {@code null} if one was not specified
|
||||||
* @param suppressFailureLogClasses classes for which we do not need or want to log Entitlements failures
|
* @param suppressFailureLogPackages packages for which we do not need or want to log Entitlements failures
|
||||||
*/
|
*/
|
||||||
public static void bootstrap(
|
public static void bootstrap(
|
||||||
Policy serverPolicyPatch,
|
Policy serverPolicyPatch,
|
||||||
|
@ -95,7 +95,7 @@ public class EntitlementBootstrap {
|
||||||
Path logsDir,
|
Path logsDir,
|
||||||
Path tempDir,
|
Path tempDir,
|
||||||
Path pidFile,
|
Path pidFile,
|
||||||
Set<Class<?>> suppressFailureLogClasses
|
Set<Package> suppressFailureLogPackages
|
||||||
) {
|
) {
|
||||||
logger.debug("Loading entitlement agent");
|
logger.debug("Loading entitlement agent");
|
||||||
if (EntitlementBootstrap.bootstrapArgs != null) {
|
if (EntitlementBootstrap.bootstrapArgs != null) {
|
||||||
|
@ -119,7 +119,7 @@ public class EntitlementBootstrap {
|
||||||
settingResolver
|
settingResolver
|
||||||
),
|
),
|
||||||
sourcePaths,
|
sourcePaths,
|
||||||
suppressFailureLogClasses
|
suppressFailureLogPackages
|
||||||
);
|
);
|
||||||
exportInitializationToAgent();
|
exportInitializationToAgent();
|
||||||
loadAgent(findAgentJar());
|
loadAgent(findAgentJar());
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class EntitlementInitialization {
|
||||||
EntitlementBootstrap.bootstrapArgs().sourcePaths(),
|
EntitlementBootstrap.bootstrapArgs().sourcePaths(),
|
||||||
ENTITLEMENTS_MODULE,
|
ENTITLEMENTS_MODULE,
|
||||||
pathLookup,
|
pathLookup,
|
||||||
bootstrapArgs.suppressFailureLogClasses()
|
bootstrapArgs.suppressFailureLogPackages()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -256,7 +256,7 @@ public class PolicyManager {
|
||||||
private final Map<String, Map<String, List<Entitlement>>> pluginsEntitlements;
|
private final Map<String, Map<String, List<Entitlement>>> pluginsEntitlements;
|
||||||
private final Function<Class<?>, PolicyScope> scopeResolver;
|
private final Function<Class<?>, PolicyScope> scopeResolver;
|
||||||
private final PathLookup pathLookup;
|
private final PathLookup pathLookup;
|
||||||
private final Set<Class<?>> mutedClasses;
|
private final Set<Package> suppressFailureLogPackages;
|
||||||
|
|
||||||
public static final String ALL_UNNAMED = "ALL-UNNAMED";
|
public static final String ALL_UNNAMED = "ALL-UNNAMED";
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ public class PolicyManager {
|
||||||
Map<String, Path> sourcePaths,
|
Map<String, Path> sourcePaths,
|
||||||
Module entitlementsModule,
|
Module entitlementsModule,
|
||||||
PathLookup pathLookup,
|
PathLookup pathLookup,
|
||||||
Set<Class<?>> suppressFailureLogClasses
|
Set<Package> suppressFailureLogPackages
|
||||||
) {
|
) {
|
||||||
this.serverEntitlements = buildScopeEntitlementsMap(requireNonNull(serverPolicy));
|
this.serverEntitlements = buildScopeEntitlementsMap(requireNonNull(serverPolicy));
|
||||||
this.apmAgentEntitlements = apmAgentEntitlements;
|
this.apmAgentEntitlements = apmAgentEntitlements;
|
||||||
|
@ -322,7 +322,7 @@ public class PolicyManager {
|
||||||
this.sourcePaths = sourcePaths;
|
this.sourcePaths = sourcePaths;
|
||||||
this.entitlementsModule = entitlementsModule;
|
this.entitlementsModule = entitlementsModule;
|
||||||
this.pathLookup = requireNonNull(pathLookup);
|
this.pathLookup = requireNonNull(pathLookup);
|
||||||
this.mutedClasses = suppressFailureLogClasses;
|
this.suppressFailureLogPackages = suppressFailureLogPackages;
|
||||||
|
|
||||||
List<ExclusiveFileEntitlement> exclusiveFileEntitlements = new ArrayList<>();
|
List<ExclusiveFileEntitlement> exclusiveFileEntitlements = new ArrayList<>();
|
||||||
for (var e : serverEntitlements.entrySet()) {
|
for (var e : serverEntitlements.entrySet()) {
|
||||||
|
@ -688,8 +688,8 @@ public class PolicyManager {
|
||||||
|
|
||||||
private void notEntitled(String message, Class<?> callerClass, ModuleEntitlements entitlements) {
|
private void notEntitled(String message, Class<?> callerClass, ModuleEntitlements entitlements) {
|
||||||
var exception = new NotEntitledException(message);
|
var exception = new NotEntitledException(message);
|
||||||
// Don't emit a log for muted classes, e.g. classes containing self tests
|
// Don't emit a log for suppressed packages, e.g. packages containing self tests
|
||||||
if (mutedClasses.contains(callerClass) == false) {
|
if (suppressFailureLogPackages.contains(callerClass.getPackage()) == false) {
|
||||||
entitlements.logger().warn("Not entitled: {}", message, exception);
|
entitlements.logger().warn("Not entitled: {}", message, exception);
|
||||||
}
|
}
|
||||||
throw exception;
|
throw exception;
|
||||||
|
|
|
@ -264,7 +264,7 @@ class Elasticsearch {
|
||||||
nodeEnv.logsDir(),
|
nodeEnv.logsDir(),
|
||||||
nodeEnv.tmpDir(),
|
nodeEnv.tmpDir(),
|
||||||
args.pidFile(),
|
args.pidFile(),
|
||||||
Set.of(EntitlementSelfTester.class)
|
Set.of(EntitlementSelfTester.class.getPackage())
|
||||||
);
|
);
|
||||||
EntitlementSelfTester.entitlementSelfTest();
|
EntitlementSelfTester.entitlementSelfTest();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue