Skip to content

Commit e146bde

Browse files
committed
Moved configuration reloading to a single dedicated thread
Signed-off-by: Nils Bandener <[email protected]>
1 parent 58f51fc commit e146bde

File tree

5 files changed

+376
-75
lines changed

5 files changed

+376
-75
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1111

1212
- [Resource Sharing] Keep track of list of principals for which sharable resource is visible for searching ([#5596](https://github.com/opensearch-project/security/pull/5596))
1313
- [Resource Sharing] Keep track of tenant for sharable resources by persisting user requested tenant with sharing info ([#5588](https://github.com/opensearch-project/security/pull/5588))
14+
- Moved configuration reloading to dedicated thread to improve node stability ([#5479](https://github.com/opensearch-project/security/pull/5479))
1415

1516
### Bug Fixes
1617

src/main/java/org/opensearch/security/OpenSearchSecurityPlugin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,7 @@ public Collection<Object> createComponents(
11641164
final XFFResolver xffResolver = new XFFResolver(threadPool);
11651165
backendRegistry = new BackendRegistry(settings, adminDns, xffResolver, auditLog, threadPool, cih);
11661166
backendRegistry.registerClusterSettingsChangeListener(clusterService.getClusterSettings());
1167+
cr.subscribeOnChange(configMap -> { backendRegistry.invalidateCache(); });
11671168
tokenManager = new SecurityTokenManager(cs, threadPool, userService);
11681169

11691170
final CompatConfig compatConfig = new CompatConfig(environment, transportPassiveAuthSetting);

src/main/java/org/opensearch/security/action/configupdate/TransportConfigUpdateAction.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import org.opensearch.core.common.io.stream.StreamOutput;
4545
import org.opensearch.security.auth.BackendRegistry;
4646
import org.opensearch.security.configuration.ConfigurationRepository;
47-
import org.opensearch.security.securityconf.DynamicConfigFactory;
4847
import org.opensearch.security.securityconf.impl.CType;
4948
import org.opensearch.threadpool.ThreadPool;
5049
import org.opensearch.transport.TransportRequest;
@@ -59,7 +58,6 @@ public class TransportConfigUpdateAction extends TransportNodesAction<
5958
protected Logger logger = LogManager.getLogger(getClass());
6059
private final Provider<BackendRegistry> backendRegistry;
6160
private final ConfigurationRepository configurationRepository;
62-
private DynamicConfigFactory dynamicConfigFactory;
6361
private static final Set<CType<?>> SELECTIVE_VALIDATION_TYPES = Set.of(CType.INTERNALUSERS);
6462
// Note: While INTERNALUSERS is used as a marker, the cache invalidation
6563
// applies to all user types (internal, LDAP, etc.)
@@ -72,8 +70,7 @@ public TransportConfigUpdateAction(
7270
final TransportService transportService,
7371
final ConfigurationRepository configurationRepository,
7472
final ActionFilters actionFilters,
75-
Provider<BackendRegistry> backendRegistry,
76-
DynamicConfigFactory dynamicConfigFactory
73+
Provider<BackendRegistry> backendRegistry
7774
) {
7875
super(
7976
ConfigUpdateAction.NAME,
@@ -89,7 +86,6 @@ public TransportConfigUpdateAction(
8986

9087
this.configurationRepository = configurationRepository;
9188
this.backendRegistry = backendRegistry;
92-
this.dynamicConfigFactory = dynamicConfigFactory;
9389
}
9490

9591
public static class NodeConfigUpdateRequest extends TransportRequest {
@@ -133,10 +129,7 @@ protected ConfigUpdateNodeResponse nodeOperation(final NodeConfigUpdateRequest r
133129
if (canHandleSelectively(configupdateRequest)) {
134130
backendRegistry.get().invalidateUserCache(configupdateRequest.getEntityNames());
135131
} else {
136-
boolean didReload = configurationRepository.reloadConfiguration(CType.fromStringValues((configupdateRequest.getConfigTypes())));
137-
if (didReload) {
138-
backendRegistry.get().invalidateCache();
139-
}
132+
configurationRepository.reloadConfiguration(CType.fromStringValues((configupdateRequest.getConfigTypes())));
140133
}
141134
return new ConfigUpdateNodeResponse(clusterService.localNode(), configupdateRequest.getConfigTypes(), null);
142135
}

0 commit comments

Comments
 (0)