Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Features

### Enhancements
- Moved configuration reloading to dedicated thread to improve node stability ([#5479](https://github.com/opensearch-project/security/pull/5479))
- Makes resource settings dynamic ([#5677](https://github.com/opensearch-project/security/pull/5677))

### Bug Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,7 @@ public Collection<Object> createComponents(
final XFFResolver xffResolver = new XFFResolver(threadPool);
backendRegistry = new BackendRegistry(settings, adminDns, xffResolver, auditLog, threadPool, cih);
backendRegistry.registerClusterSettingsChangeListener(clusterService.getClusterSettings());
cr.subscribeOnChange(configMap -> { backendRegistry.invalidateCache(); });
tokenManager = new SecurityTokenManager(cs, threadPool, userService);

final CompatConfig compatConfig = new CompatConfig(environment, transportPassiveAuthSetting);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@

import org.opensearch.action.FailedNodeException;
import org.opensearch.action.support.ActionFilters;
import org.opensearch.action.support.nodes.TransportNodesAction;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.inject.Inject;
import org.opensearch.common.inject.Provider;
import org.opensearch.common.settings.Settings;
import org.opensearch.core.action.ActionListener;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.security.auth.BackendRegistry;
import org.opensearch.security.configuration.ConfigurationRepository;
import org.opensearch.security.securityconf.DynamicConfigFactory;
import org.opensearch.security.securityconf.impl.CType;
import org.opensearch.security.util.TransportNodesAsyncAction;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportRequest;
import org.opensearch.transport.TransportService;

public class TransportConfigUpdateAction extends TransportNodesAction<
public class TransportConfigUpdateAction extends TransportNodesAsyncAction<
ConfigUpdateRequest,
ConfigUpdateResponse,
TransportConfigUpdateAction.NodeConfigUpdateRequest,
Expand All @@ -59,7 +59,6 @@ public class TransportConfigUpdateAction extends TransportNodesAction<
protected Logger logger = LogManager.getLogger(getClass());
private final Provider<BackendRegistry> backendRegistry;
private final ConfigurationRepository configurationRepository;
private DynamicConfigFactory dynamicConfigFactory;
private static final Set<CType<?>> SELECTIVE_VALIDATION_TYPES = Set.of(CType.INTERNALUSERS);
// Note: While INTERNALUSERS is used as a marker, the cache invalidation
// applies to all user types (internal, LDAP, etc.)
Expand All @@ -72,8 +71,7 @@ public TransportConfigUpdateAction(
final TransportService transportService,
final ConfigurationRepository configurationRepository,
final ActionFilters actionFilters,
Provider<BackendRegistry> backendRegistry,
DynamicConfigFactory dynamicConfigFactory
Provider<BackendRegistry> backendRegistry
) {
super(
ConfigUpdateAction.NAME,
Expand All @@ -84,12 +82,12 @@ public TransportConfigUpdateAction(
ConfigUpdateRequest::new,
TransportConfigUpdateAction.NodeConfigUpdateRequest::new,
ThreadPool.Names.MANAGEMENT,
ThreadPool.Names.SAME,
ConfigUpdateNodeResponse.class
);

this.configurationRepository = configurationRepository;
this.backendRegistry = backendRegistry;
this.dynamicConfigFactory = dynamicConfigFactory;
}

public static class NodeConfigUpdateRequest extends TransportRequest {
Expand Down Expand Up @@ -128,17 +126,29 @@ protected ConfigUpdateResponse newResponse(
}

@Override
protected ConfigUpdateNodeResponse nodeOperation(final NodeConfigUpdateRequest request) {
protected void nodeOperation(NodeConfigUpdateRequest request, ActionListener<ConfigUpdateNodeResponse> listener) {
final var configupdateRequest = request.request;
if (canHandleSelectively(configupdateRequest)) {
backendRegistry.get().invalidateUserCache(configupdateRequest.getEntityNames());
listener.onResponse(new ConfigUpdateNodeResponse(clusterService.localNode(), configupdateRequest.getConfigTypes(), null));
} else {
boolean didReload = configurationRepository.reloadConfiguration(CType.fromStringValues((configupdateRequest.getConfigTypes())));
if (didReload) {
backendRegistry.get().invalidateCache();
}
configurationRepository.reloadConfiguration(
CType.fromStringValues((configupdateRequest.getConfigTypes())),
new ActionListener<>() {
@Override
public void onResponse(ConfigurationRepository.ConfigReloadResponse configReloadResponse) {
listener.onResponse(
new ConfigUpdateNodeResponse(clusterService.localNode(), configupdateRequest.getConfigTypes(), null)
);
}

@Override
public void onFailure(Exception e) {
listener.onFailure(e);
}
}
);
}
return new ConfigUpdateNodeResponse(clusterService.localNode(), configupdateRequest.getConfigTypes(), null);
}

private boolean canHandleSelectively(ConfigUpdateRequest request) {
Expand Down

This file was deleted.

Loading
Loading