Skip to content

Commit

Permalink
fix feature reset call lost for ESSingleNodeTestCase (elastic#79150)
Browse files Browse the repository at this point in the history
call feature reset API for all plugins inside LocalStateCompositeXPackPlugin
  • Loading branch information
Hendrik Muhs authored Oct 14, 2021
1 parent b4bcb86 commit a09f10b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
*/
package org.elasticsearch.xpack.core;

import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.RequestValidators;
import org.elasticsearch.action.admin.cluster.snapshots.features.ResetFeatureStateResponse;
import org.elasticsearch.action.admin.cluster.snapshots.features.ResetFeatureStateResponse.ResetFeatureStateStatus;
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest;
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
import org.elasticsearch.action.support.ActionFilter;
import org.elasticsearch.action.support.GroupedActionListener;
import org.elasticsearch.bootstrap.BootstrapCheck;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.ClusterState;
Expand All @@ -37,7 +41,6 @@
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.common.util.PageCacheRecycler;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.xcontent.NamedXContentRegistry;
import org.elasticsearch.core.internal.io.IOUtils;
import org.elasticsearch.env.Environment;
import org.elasticsearch.env.NodeEnvironment;
Expand Down Expand Up @@ -85,6 +88,7 @@
import org.elasticsearch.transport.Transport;
import org.elasticsearch.transport.TransportInterceptor;
import org.elasticsearch.watcher.ResourceWatcherService;
import org.elasticsearch.xcontent.NamedXContentRegistry;
import org.elasticsearch.xpack.core.ssl.SSLService;

import java.io.IOException;
Expand Down Expand Up @@ -591,10 +595,30 @@ public CheckedBiConsumer<ShardSearchRequest, StreamOutput, IOException> getReque

}

@Override
public void cleanUpFeature(
ClusterService clusterService,
Client client,
ActionListener<ResetFeatureStateResponse.ResetFeatureStateStatus> finalListener
) {
List<SystemIndexPlugin> systemPlugins = filterPlugins(SystemIndexPlugin.class);

GroupedActionListener<ResetFeatureStateResponse.ResetFeatureStateStatus> allListeners = new GroupedActionListener<>(
ActionListener.wrap(
listenerResults -> finalListener.onResponse(ResetFeatureStateStatus.success(getFeatureName())),
finalListener::onFailure
),
systemPlugins.size()
);
systemPlugins.forEach(plugin -> plugin.cleanUpFeature(clusterService, client, allListeners));
}

@Override
public boolean safeToShutdown(String nodeId, SingleNodeShutdownMetadata.Type shutdownType) {
return filterPlugins(ShutdownAwarePlugin.class).stream().allMatch(plugin -> plugin.safeToShutdown(nodeId, shutdownType));
}

@Override
public void signalShutdown(Collection<String> shutdownNodeIds) {
filterPlugins(ShutdownAwarePlugin.class).forEach(plugin -> plugin.signalShutdown(shutdownNodeIds));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.admin.cluster.snapshots.features.ResetFeatureStateResponse;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.TransportAction;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.breaker.NoopCircuitBreaker;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
Expand Down Expand Up @@ -80,14 +77,6 @@ protected XPackLicenseState getLicenseState() {
plugins.add(new MockedRollupPlugin());
}

@Override
public void cleanUpFeature(
ClusterService clusterService,
Client client,
ActionListener<ResetFeatureStateResponse.ResetFeatureStateStatus> finalListener) {
mlPlugin.cleanUpFeature(clusterService, client, finalListener);
}

@Override
public List<AggregationSpec> getAggregations() {
return mlPlugin.getAggregations();
Expand Down

0 comments on commit a09f10b

Please sign in to comment.