Skip to content

Commit

Permalink
All acknowledgedResponse actions are local-only (elastic#103974)
Browse files Browse the repository at this point in the history
Actions returning `AcknowledgedResponse` are for cluster state updates
which we do not send to remote clusters, so we can mark all these
actions as `localOnly()`.

Relates elastic#103242
Relates elastic#103330
  • Loading branch information
DaveCTurner authored Jan 5, 2024
1 parent a994aed commit 1847889
Show file tree
Hide file tree
Showing 23 changed files with 26 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
*/
public class DeleteDataStreamLifecycleAction {

public static final ActionType<AcknowledgedResponse> INSTANCE = ActionType.acknowledgedResponse(
"indices:admin/data_stream/lifecycle/delete"
);
public static final ActionType<AcknowledgedResponse> INSTANCE = ActionType.localOnly("indices:admin/data_stream/lifecycle/delete");

private DeleteDataStreamLifecycleAction() {/* no instances */}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
*/
public class PutDataStreamLifecycleAction {

public static final ActionType<AcknowledgedResponse> INSTANCE = ActionType.acknowledgedResponse(
"indices:admin/data_stream/lifecycle/put"
);
public static final ActionType<AcknowledgedResponse> INSTANCE = ActionType.localOnly("indices:admin/data_stream/lifecycle/put");

private PutDataStreamLifecycleAction() {/* no instances */}

Expand Down
5 changes: 0 additions & 5 deletions server/src/main/java/org/elasticsearch/action/ActionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

package org.elasticsearch.action;

import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.common.io.stream.Writeable;

/**
Expand All @@ -27,10 +26,6 @@ public static ActionType<ActionResponse.Empty> emptyResponse(String name) {
return new ActionType<>(name, in -> ActionResponse.Empty.INSTANCE);
}

public static ActionType<AcknowledgedResponse> acknowledgedResponse(String name) {
return new ActionType<>(name, AcknowledgedResponse::readFrom);
}

/**
* @param name The name of the action, must be unique across actions.
* @param responseReader A reader for the response type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
public class TransportDeleteRepositoryAction extends AcknowledgedTransportMasterNodeAction<DeleteRepositoryRequest> {

public static final ActionType<AcknowledgedResponse> TYPE = ActionType.acknowledgedResponse("cluster:admin/repository/delete");
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.localOnly("cluster:admin/repository/delete");
private final RepositoriesService repositoriesService;

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
public class TransportPutRepositoryAction extends AcknowledgedTransportMasterNodeAction<PutRepositoryRequest> {

public static final ActionType<AcknowledgedResponse> TYPE = ActionType.acknowledgedResponse("cluster:admin/repository/put");
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.localOnly("cluster:admin/repository/put");
private final RepositoriesService repositoriesService;

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
public final class TransportCloneSnapshotAction extends AcknowledgedTransportMasterNodeAction<CloneSnapshotRequest> {

public static final ActionType<AcknowledgedResponse> TYPE = ActionType.acknowledgedResponse("cluster:admin/snapshot/clone");
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.localOnly("cluster:admin/snapshot/clone");
private final SnapshotsService snapshotsService;

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* Transport action for delete snapshot operation
*/
public class TransportDeleteSnapshotAction extends AcknowledgedTransportMasterNodeAction<DeleteSnapshotRequest> {
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.acknowledgedResponse("cluster:admin/snapshot/delete");
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.localOnly("cluster:admin/snapshot/delete");
private final SnapshotsService snapshotsService;

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

public class TransportDeleteStoredScriptAction extends AcknowledgedTransportMasterNodeAction<DeleteStoredScriptRequest> {

public static final ActionType<AcknowledgedResponse> TYPE = ActionType.acknowledgedResponse("cluster:admin/script/delete");
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.localOnly("cluster:admin/script/delete");

@Inject
public TransportDeleteStoredScriptAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

public class TransportPutStoredScriptAction extends AcknowledgedTransportMasterNodeAction<PutStoredScriptRequest> {

public static final ActionType<AcknowledgedResponse> TYPE = ActionType.acknowledgedResponse("cluster:admin/script/put");
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.localOnly("cluster:admin/script/put");
private final ScriptService scriptService;

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
public class TransportIndicesAliasesAction extends AcknowledgedTransportMasterNodeAction<IndicesAliasesRequest> {

public static final String NAME = "indices:admin/aliases";
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.acknowledgedResponse(NAME);
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.localOnly(NAME);
private static final Logger logger = LogManager.getLogger(TransportIndicesAliasesAction.class);

private final MetadataIndexAliasesService indexAliasesService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
* to add the index to the index graveyard.
*/
public class TransportDeleteDanglingIndexAction extends AcknowledgedTransportMasterNodeAction<DeleteDanglingIndexRequest> {
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.acknowledgedResponse("cluster:admin/indices/dangling/delete");
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.localOnly("cluster:admin/indices/dangling/delete");
private static final Logger logger = LogManager.getLogger(TransportDeleteDanglingIndexAction.class);

private final Settings settings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* to perform the actual allocation.
*/
public class TransportImportDanglingIndexAction extends HandledTransportAction<ImportDanglingIndexRequest, AcknowledgedResponse> {
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.acknowledgedResponse("cluster:admin/indices/dangling/import");
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.localOnly("cluster:admin/indices/dangling/import");
private static final Logger logger = LogManager.getLogger(TransportImportDanglingIndexAction.class);

private final LocalAllocateDangledIndices danglingIndexAllocator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
public class TransportDeleteIndexAction extends AcknowledgedTransportMasterNodeAction<DeleteIndexRequest> {

public static final ActionType<AcknowledgedResponse> TYPE = ActionType.acknowledgedResponse("indices:admin/delete");
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.localOnly("indices:admin/delete");
private static final Logger logger = LogManager.getLogger(TransportDeleteIndexAction.class);

private final MetadataDeleteIndexService deleteIndexService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

public class TransportAutoPutMappingAction extends AcknowledgedTransportMasterNodeAction<PutMappingRequest> {

public static final ActionType<AcknowledgedResponse> TYPE = ActionType.acknowledgedResponse("indices:admin/mapping/auto_put");
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.localOnly("indices:admin/mapping/auto_put");
private static final Logger logger = LogManager.getLogger(TransportAutoPutMappingAction.class);

private final MetadataMappingService metadataMappingService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
*/
public class TransportPutMappingAction extends AcknowledgedTransportMasterNodeAction<PutMappingRequest> {

public static final ActionType<AcknowledgedResponse> TYPE = ActionType.acknowledgedResponse("indices:admin/mapping/put");
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.localOnly("indices:admin/mapping/put");
private static final Logger logger = LogManager.getLogger(TransportPutMappingAction.class);

private final MetadataMappingService metadataMappingService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

public class TransportUpdateSettingsAction extends AcknowledgedTransportMasterNodeAction<UpdateSettingsRequest> {

public static final ActionType<AcknowledgedResponse> TYPE = ActionType.acknowledgedResponse("indices:admin/settings/update");
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.localOnly("indices:admin/settings/update");
private static final Logger logger = LogManager.getLogger(TransportUpdateSettingsAction.class);

private final MetadataUpdateSettingsService updateSettingsService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
public class TransportDeleteIndexTemplateAction extends AcknowledgedTransportMasterNodeAction<DeleteIndexTemplateRequest> {

public static final ActionType<AcknowledgedResponse> TYPE = ActionType.acknowledgedResponse("indices:admin/template/delete");
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.localOnly("indices:admin/template/delete");
private static final Logger logger = LogManager.getLogger(TransportDeleteIndexTemplateAction.class);

private final MetadataIndexTemplateService indexTemplateService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
public class TransportPutIndexTemplateAction extends AcknowledgedTransportMasterNodeAction<PutIndexTemplateRequest> {

public static final ActionType<AcknowledgedResponse> TYPE = ActionType.acknowledgedResponse("indices:admin/template/put");
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.localOnly("indices:admin/template/put");
private static final Logger logger = LogManager.getLogger(TransportPutIndexTemplateAction.class);

private final MetadataIndexTemplateService indexTemplateService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

public class DeletePipelineTransportAction extends AcknowledgedTransportMasterNodeAction<DeletePipelineRequest> {

public static final ActionType<AcknowledgedResponse> TYPE = ActionType.acknowledgedResponse("cluster:admin/ingest/pipeline/delete");
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.localOnly("cluster:admin/ingest/pipeline/delete");
private final IngestService ingestService;

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import static org.elasticsearch.ingest.IngestService.INGEST_ORIGIN;

public class PutPipelineTransportAction extends AcknowledgedTransportMasterNodeAction<PutPipelineRequest> {
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.acknowledgedResponse("cluster:admin/ingest/pipeline/put");
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.localOnly("cluster:admin/ingest/pipeline/put");
private final IngestService ingestService;
private final OriginSettingClient client;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

public class TransportDeleteLicenseAction extends AcknowledgedTransportMasterNodeAction<DeleteLicenseRequest> {

public static final ActionType<AcknowledgedResponse> TYPE = ActionType.acknowledgedResponse("cluster:admin/xpack/license/delete");
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.localOnly("cluster:admin/xpack/license/delete");
private final MutableLicenseService licenseService;

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import static org.elasticsearch.xpack.core.ClientHelper.ASYNC_SEARCH_ORIGIN;

public class TransportDeleteAsyncResultAction extends HandledTransportAction<DeleteAsyncResultRequest, AcknowledgedResponse> {
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.acknowledgedResponse("indices:data/read/async_search/delete");
public static final ActionType<AcknowledgedResponse> TYPE = ActionType.localOnly("indices:data/read/async_search/delete");
private final DeleteAsyncResultsService deleteResultsService;
private final ClusterService clusterService;
private final TransportService transportService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

public enum ILMActions {
;
public static final ActionType<AcknowledgedResponse> START = ActionType.acknowledgedResponse("cluster:admin/ilm/start");
public static final ActionType<AcknowledgedResponse> STOP = ActionType.acknowledgedResponse("cluster:admin/ilm/stop");
public static final ActionType<AcknowledgedResponse> RETRY = ActionType.acknowledgedResponse("indices:admin/ilm/retry");
public static final ActionType<AcknowledgedResponse> MOVE_TO_STEP = ActionType.acknowledgedResponse("cluster:admin/ilm/_move/post");
public static final ActionType<AcknowledgedResponse> PUT = ActionType.acknowledgedResponse("cluster:admin/ilm/put");
public static final ActionType<AcknowledgedResponse> START = ActionType.localOnly("cluster:admin/ilm/start");
public static final ActionType<AcknowledgedResponse> STOP = ActionType.localOnly("cluster:admin/ilm/stop");
public static final ActionType<AcknowledgedResponse> RETRY = ActionType.localOnly("indices:admin/ilm/retry");
public static final ActionType<AcknowledgedResponse> MOVE_TO_STEP = ActionType.localOnly("cluster:admin/ilm/_move/post");
public static final ActionType<AcknowledgedResponse> PUT = ActionType.localOnly("cluster:admin/ilm/put");
}

0 comments on commit 1847889

Please sign in to comment.