From 8021fab6964be14f5d55590f726a9e9ae19a29b0 Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Tue, 27 Jul 2021 11:19:28 -0600 Subject: [PATCH 01/17] Add (failing) test to reproduce bug --- .../xpack/shutdown/NodeShutdownShardsIT.java | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java diff --git a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java new file mode 100644 index 0000000000000..3fbe3a7fc75b3 --- /dev/null +++ b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java @@ -0,0 +1,75 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +package org.elasticsearch.xpack.shutdown; + +import org.elasticsearch.Build; +import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; +import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; +import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata; +import org.elasticsearch.cluster.node.DiscoveryNode; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.test.ESIntegTestCase; + +import java.util.Arrays; +import java.util.Collection; + +import static org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata.Status.COMPLETE; +import static org.hamcrest.Matchers.equalTo; + +@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, numClientNodes = 0) +public class NodeShutdownShardsIT extends ESIntegTestCase { + + @Override + protected Collection> nodePlugins() { + return Arrays.asList(ShutdownPlugin.class); + } + + public void testReproduceNotStartedBug() throws Exception { + assumeTrue("must be on a snapshot build of ES to run in order for the feature flag to be set", Build.CURRENT.isSnapshot()); + final String nodeToRestartName = internalCluster().startNode(); + final String nodeToRestartId = getNodeId(nodeToRestartName); + Settings nodeToRestartDataPathSettings = internalCluster().dataPathSettings(nodeToRestartName); + internalCluster().startNode(); + + // Mark the node for shutdown + PutShutdownNodeAction.Request putShutdownRequest = new PutShutdownNodeAction.Request( + nodeToRestartId, + SingleNodeShutdownMetadata.Type.REMOVE, + this.getTestName() + ); + AcknowledgedResponse putShutdownResponse = client().execute(PutShutdownNodeAction.INSTANCE, putShutdownRequest).get(); + assertTrue(putShutdownResponse.isAcknowledged()); + + internalCluster().stopNode(nodeToRestartName); + + assertBusy(() -> { + NodesInfoResponse nodes = client().admin().cluster().prepareNodesInfo().clear().get(); + assertThat(nodes.getNodes().size(), equalTo(1)); + }); + + GetShutdownStatusAction.Response getResp = client().execute( + GetShutdownStatusAction.INSTANCE, + new GetShutdownStatusAction.Request(nodeToRestartId) + ).get(); + + assertThat(getResp.getShutdownStatuses().get(0).migrationStatus().getStatus(), equalTo(COMPLETE)); + } + + private String getNodeId(String nodeName) throws Exception { + NodesInfoResponse nodes = client().admin().cluster().prepareNodesInfo().clear().get(); + return nodes.getNodes() + .stream() + .map(NodeInfo::getNode) + .filter(node -> node.getName().equals(nodeName)) + .map(DiscoveryNode::getId) + .findFirst() + .orElseThrow(); + } +} From f3960d00601f57cbac6f36dbe6bedd2bd3dd88a2 Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Tue, 27 Jul 2021 11:23:04 -0600 Subject: [PATCH 02/17] Add another test for another case of the bug --- .../xpack/shutdown/NodeShutdownShardsIT.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java index 3fbe3a7fc75b3..deea87c782989 100644 --- a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java +++ b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java @@ -62,6 +62,29 @@ public void testReproduceNotStartedBug() throws Exception { assertThat(getResp.getShutdownStatuses().get(0).migrationStatus().getStatus(), equalTo(COMPLETE)); } + public void testNotStartedBugOnDedicatedMaster() throws Exception { + assumeTrue("must be on a snapshot build of ES to run in order for the feature flag to be set", Build.CURRENT.isSnapshot()); + final String nodeToShutDownName = internalCluster().startMasterOnlyNode(); + internalCluster().startMasterOnlyNode(); // Just to have at least one other node + final String nodeToRestartId = getNodeId(nodeToShutDownName); + + // Mark the node for shutdown + PutShutdownNodeAction.Request putShutdownRequest = new PutShutdownNodeAction.Request( + nodeToRestartId, + SingleNodeShutdownMetadata.Type.REMOVE, + this.getTestName() + ); + AcknowledgedResponse putShutdownResponse = client().execute(PutShutdownNodeAction.INSTANCE, putShutdownRequest).get(); + assertTrue(putShutdownResponse.isAcknowledged()); + + GetShutdownStatusAction.Response getResp = client().execute( + GetShutdownStatusAction.INSTANCE, + new GetShutdownStatusAction.Request(nodeToRestartId) + ).get(); + + assertThat(getResp.getShutdownStatuses().get(0).migrationStatus().getStatus(), equalTo(COMPLETE)); + } + private String getNodeId(String nodeName) throws Exception { NodesInfoResponse nodes = client().admin().cluster().prepareNodesInfo().clear().get(); return nodes.getNodes() From 2aed2f1e78d5316fee720e6ffd6faf053d1eeda2 Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Tue, 27 Jul 2021 11:23:55 -0600 Subject: [PATCH 03/17] Minor cleanup --- .../elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java index deea87c782989..92102bf2e0d68 100644 --- a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java +++ b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java @@ -35,7 +35,6 @@ public void testReproduceNotStartedBug() throws Exception { assumeTrue("must be on a snapshot build of ES to run in order for the feature flag to be set", Build.CURRENT.isSnapshot()); final String nodeToRestartName = internalCluster().startNode(); final String nodeToRestartId = getNodeId(nodeToRestartName); - Settings nodeToRestartDataPathSettings = internalCluster().dataPathSettings(nodeToRestartName); internalCluster().startNode(); // Mark the node for shutdown @@ -49,10 +48,8 @@ public void testReproduceNotStartedBug() throws Exception { internalCluster().stopNode(nodeToRestartName); - assertBusy(() -> { - NodesInfoResponse nodes = client().admin().cluster().prepareNodesInfo().clear().get(); - assertThat(nodes.getNodes().size(), equalTo(1)); - }); + NodesInfoResponse nodes = client().admin().cluster().prepareNodesInfo().clear().get(); + assertThat(nodes.getNodes().size(), equalTo(1)); GetShutdownStatusAction.Response getResp = client().execute( GetShutdownStatusAction.INSTANCE, From d619654bec3c58d9a22bb6ff00743199cf61bc82 Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Tue, 27 Jul 2021 11:29:32 -0600 Subject: [PATCH 04/17] Remove unused imports --- .../org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java index 92102bf2e0d68..b804b5323582c 100644 --- a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java +++ b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java @@ -13,7 +13,6 @@ import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.common.settings.Settings; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESIntegTestCase; From 9a0f6d5b1a4cb2c59bf20b1bfad1739df2739f3d Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Mon, 2 Aug 2021 14:44:08 -0600 Subject: [PATCH 05/17] Fix `NOT_STARTED` shard migration status appearing for non-data nodes --- .../shutdown/TransportGetShutdownStatusAction.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java index 009e0f6a78caa..290999a67505b 100644 --- a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java +++ b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java @@ -23,6 +23,7 @@ import org.elasticsearch.cluster.metadata.ShutdownPluginsStatus; import org.elasticsearch.cluster.metadata.ShutdownShardMigrationStatus; import org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata; +import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.ShardRoutingState; import org.elasticsearch.cluster.routing.allocation.AllocationDecision; @@ -172,8 +173,8 @@ static ShutdownShardMigrationStatus shardMigrationStatus( ); } - if (currentState.getRoutingNodes().node(nodeId) == null) { - // We don't know about that node + if (currentState.nodes().get(nodeId) == null) { + // The node isn't in the cluster return new ShutdownShardMigrationStatus( SingleNodeShutdownMetadata.Status.NOT_STARTED, 0, @@ -181,6 +182,15 @@ static ShutdownShardMigrationStatus shardMigrationStatus( ); } + // The node is in `DiscoveryNodes`, but not `RoutingNodes` - so there are no shards assigned to it. We're done. + if (currentState.getRoutingNodes().node(nodeId) == null) { + // We don't know about that node + return new ShutdownShardMigrationStatus( + SingleNodeShutdownMetadata.Status.COMPLETE, + 0 + ); + } + // First, check if there are any shards currently on this node, and if there are any relocating shards int startedShards = currentState.getRoutingNodes().node(nodeId).numberOfShardsWithState(ShardRoutingState.STARTED); int relocatingShards = currentState.getRoutingNodes().node(nodeId).numberOfShardsWithState(ShardRoutingState.RELOCATING); From 2d740f9e920027dc39622a847cb4670fcda91bb0 Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Thu, 12 Aug 2021 14:27:11 -0600 Subject: [PATCH 06/17] Imports --- .../xpack/shutdown/TransportGetShutdownStatusAction.java | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java index 290999a67505b..39272b64f3947 100644 --- a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java +++ b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java @@ -23,7 +23,6 @@ import org.elasticsearch.cluster.metadata.ShutdownPluginsStatus; import org.elasticsearch.cluster.metadata.ShutdownShardMigrationStatus; import org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata; -import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.ShardRoutingState; import org.elasticsearch.cluster.routing.allocation.AllocationDecision; From 14f681fbda35591bc6b817a02ea46a58eec98ff2 Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Thu, 12 Aug 2021 14:47:46 -0600 Subject: [PATCH 07/17] spotless --- .../xpack/shutdown/TransportGetShutdownStatusAction.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java index 39272b64f3947..c9797f690108f 100644 --- a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java +++ b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java @@ -184,10 +184,7 @@ static ShutdownShardMigrationStatus shardMigrationStatus( // The node is in `DiscoveryNodes`, but not `RoutingNodes` - so there are no shards assigned to it. We're done. if (currentState.getRoutingNodes().node(nodeId) == null) { // We don't know about that node - return new ShutdownShardMigrationStatus( - SingleNodeShutdownMetadata.Status.COMPLETE, - 0 - ); + return new ShutdownShardMigrationStatus(SingleNodeShutdownMetadata.Status.COMPLETE, 0); } // First, check if there are any shards currently on this node, and if there are any relocating shards From ca88ade7038504aebed4c1bf8574b394c430829c Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Thu, 12 Aug 2021 16:48:44 -0600 Subject: [PATCH 08/17] Add node-seen tracking to shutdown metadata --- .../metadata/SingleNodeShutdownMetadata.java | 42 +++++++-- .../metadata/NodesShutdownMetadataTests.java | 1 + .../xpack/shutdown/ShutdownService.java | 85 +++++++++++++++++++ .../TransportGetShutdownStatusAction.java | 17 ++-- .../TransportPutShutdownNodeAction.java | 3 + ...TransportGetShutdownStatusActionTests.java | 40 +++++---- 6 files changed, 159 insertions(+), 29 deletions(-) create mode 100644 x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownService.java diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/SingleNodeShutdownMetadata.java b/server/src/main/java/org/elasticsearch/cluster/metadata/SingleNodeShutdownMetadata.java index bfe73c4d409d9..27c66befce4e0 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/SingleNodeShutdownMetadata.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/SingleNodeShutdownMetadata.java @@ -35,6 +35,7 @@ public class SingleNodeShutdownMetadata extends AbstractDiffable PARSER = new ConstructingObjectParser<>( "node_shutdown_info", @@ -42,7 +43,8 @@ public class SingleNodeShutdownMetadata extends AbstractDiffable nodesNotPreviouslySeen = eventShutdownMetadata.getAllNodeMetadataMap() + .values() + .stream() + .filter(singleNodeShutdownMetadata -> singleNodeShutdownMetadata.getNodeSeen() == false) + .map(SingleNodeShutdownMetadata::getNodeId) + .filter(nodeId -> event.state().nodes().nodeExists(nodeId)) + .collect(Collectors.toUnmodifiableSet()); + + if (nodesNotPreviouslySeen.isEmpty() == false) { + clusterService.submitStateUpdateTask("shutdown-seen-nodes-updater", new ClusterStateUpdateTask() { + @Override + public ClusterState execute(ClusterState currentState) throws Exception { + NodesShutdownMetadata shutdownMetadata = currentState.metadata().custom(NodesShutdownMetadata.TYPE); + + final Map newShutdownMetadataMap = shutdownMetadata.getAllNodeMetadataMap() + .values() + .stream() + .map(singleNodeShutdownMetadata -> { + if (nodesNotPreviouslySeen.contains(singleNodeShutdownMetadata.getNodeId())) { + return SingleNodeShutdownMetadata.builder(singleNodeShutdownMetadata).setNodeSeen(true).build(); + } + return singleNodeShutdownMetadata; + }) + .collect(Collectors.toUnmodifiableMap(SingleNodeShutdownMetadata::getNodeId, Function.identity())); + + return ClusterState.builder(currentState) + .metadata( + Metadata.builder(currentState.metadata()) + .putCustom(NodesShutdownMetadata.TYPE, new NodesShutdownMetadata(newShutdownMetadataMap)) + .build() + ) + .build(); + } + + @Override + public void onFailure(String source, Exception e) { + logger.warn(new ParameterizedMessage("failed to mark shutting down nodes as seen: {}", nodesNotPreviouslySeen), e); + } + }); + } + } +} diff --git a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java index c9797f690108f..a7af8666d62cf 100644 --- a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java +++ b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java @@ -112,10 +112,11 @@ protected void masterOperation( state, ns.getNodeId(), ns.getType(), - allocationDeciders, + ns.getNodeSeen(), clusterInfoService, snapshotsInfoService, - allocationService + allocationService, + allocationDeciders ), new ShutdownPersistentTasksStatus(), new ShutdownPluginsStatus(pluginShutdownService.readyToShutdown(ns.getNodeId(), ns.getType())) @@ -136,10 +137,11 @@ protected void masterOperation( state, ns.getNodeId(), ns.getType(), - allocationDeciders, + ns.getNodeSeen(), clusterInfoService, snapshotsInfoService, - allocationService + allocationService, + allocationDeciders ), new ShutdownPersistentTasksStatus(), new ShutdownPluginsStatus(pluginShutdownService.readyToShutdown(ns.getNodeId(), ns.getType())) @@ -158,10 +160,11 @@ static ShutdownShardMigrationStatus shardMigrationStatus( ClusterState currentState, String nodeId, SingleNodeShutdownMetadata.Type shutdownType, - AllocationDeciders allocationDeciders, + boolean nodeSeen, ClusterInfoService clusterInfoService, SnapshotsInfoService snapshotsInfoService, - AllocationService allocationService + AllocationService allocationService, + AllocationDeciders allocationDeciders ) { // Only REMOVE-type shutdowns will try to move shards, so RESTART-type shutdowns should immediately complete if (SingleNodeShutdownMetadata.Type.RESTART.equals(shutdownType)) { @@ -172,7 +175,7 @@ static ShutdownShardMigrationStatus shardMigrationStatus( ); } - if (currentState.nodes().get(nodeId) == null) { + if (currentState.nodes().get(nodeId) == null && nodeSeen == false) { // The node isn't in the cluster return new ShutdownShardMigrationStatus( SingleNodeShutdownMetadata.Status.NOT_STARTED, diff --git a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportPutShutdownNodeAction.java b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportPutShutdownNodeAction.java index 19c06341b9003..bdd31f3914158 100644 --- a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportPutShutdownNodeAction.java +++ b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportPutShutdownNodeAction.java @@ -82,11 +82,14 @@ public ClusterState execute(ClusterState currentState) { ); } + final boolean nodeSeen = currentState.getNodes().nodeExists(request.getNodeId()); + SingleNodeShutdownMetadata newNodeMetadata = SingleNodeShutdownMetadata.builder() .setNodeId(request.getNodeId()) .setType(request.getType()) .setReason(request.getReason()) .setStartedAtMillis(System.currentTimeMillis()) + .setNodeSeen(nodeSeen) .build(); return ClusterState.builder(currentState) diff --git a/x-pack/plugin/shutdown/src/test/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusActionTests.java b/x-pack/plugin/shutdown/src/test/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusActionTests.java index 4db2e6ad2d37f..1aaa13e79b746 100644 --- a/x-pack/plugin/shutdown/src/test/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusActionTests.java +++ b/x-pack/plugin/shutdown/src/test/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusActionTests.java @@ -129,10 +129,11 @@ public void testEmptyCluster() { state, SHUTTING_DOWN_NODE_ID, SingleNodeShutdownMetadata.Type.REMOVE, - allocationDeciders, + false, clusterInfoService, snapshotsInfoService, - allocationService + allocationService, + allocationDeciders ); assertShardMigration(status, SingleNodeShutdownMetadata.Status.COMPLETE, 0, nullValue()); @@ -158,10 +159,11 @@ public void testRestartAlwaysComplete() { state, SHUTTING_DOWN_NODE_ID, SingleNodeShutdownMetadata.Type.RESTART, - allocationDeciders, + randomBoolean(), // Whether the node has been seen doesn't matter, restart-type shutdowns should always say COMPLETE here. clusterInfoService, snapshotsInfoService, - allocationService + allocationService, + allocationDeciders ); assertShardMigration( @@ -193,10 +195,11 @@ public void testComplete() { state, SHUTTING_DOWN_NODE_ID, SingleNodeShutdownMetadata.Type.REMOVE, - allocationDeciders, + true, clusterInfoService, snapshotsInfoService, - allocationService + allocationService, + allocationDeciders ); assertShardMigration(status, SingleNodeShutdownMetadata.Status.COMPLETE, 0, nullValue()); @@ -237,10 +240,11 @@ public void testInProgressWithRelocatingShards() { state, SHUTTING_DOWN_NODE_ID, SingleNodeShutdownMetadata.Type.REMOVE, - allocationDeciders, + true, clusterInfoService, snapshotsInfoService, - allocationService + allocationService, + allocationDeciders ); assertShardMigration(status, SingleNodeShutdownMetadata.Status.IN_PROGRESS, 2, nullValue()); @@ -288,10 +292,11 @@ public void testInProgressWithShardsMovingBetweenOtherNodes() { state, SHUTTING_DOWN_NODE_ID, SingleNodeShutdownMetadata.Type.REMOVE, - allocationDeciders, + true, clusterInfoService, snapshotsInfoService, - allocationService + allocationService, + allocationDeciders ); assertShardMigration(status, SingleNodeShutdownMetadata.Status.IN_PROGRESS, 1, nullValue()); @@ -323,10 +328,11 @@ public void testStalled() { state, SHUTTING_DOWN_NODE_ID, SingleNodeShutdownMetadata.Type.REMOVE, - allocationDeciders, + true, clusterInfoService, snapshotsInfoService, - allocationService + allocationService, + allocationDeciders ); assertShardMigration( @@ -354,10 +360,11 @@ public void testOnlyInitializingShardsRemaining() { state, SHUTTING_DOWN_NODE_ID, SingleNodeShutdownMetadata.Type.REMOVE, - allocationDeciders, + true, clusterInfoService, snapshotsInfoService, - allocationService + allocationService, + allocationDeciders ); assertShardMigration( @@ -429,10 +436,11 @@ public void testNodeNotInCluster() { state, bogusNodeId, SingleNodeShutdownMetadata.Type.REMOVE, - allocationDeciders, + false, clusterInfoService, snapshotsInfoService, - allocationService + allocationService, + allocationDeciders ); assertShardMigration(status, SingleNodeShutdownMetadata.Status.NOT_STARTED, 0, is("node is not currently part of the cluster")); From 8a7f0dea6a51b9e13954ce1783b552c8e869b608 Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Thu, 12 Aug 2021 16:50:42 -0600 Subject: [PATCH 09/17] Fix test names --- .../elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java index b804b5323582c..3e504f9b939ca 100644 --- a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java +++ b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java @@ -30,7 +30,7 @@ protected Collection> nodePlugins() { return Arrays.asList(ShutdownPlugin.class); } - public void testReproduceNotStartedBug() throws Exception { + public void testShardStatusStaysCompleteAfterNodeLeaves() throws Exception { assumeTrue("must be on a snapshot build of ES to run in order for the feature flag to be set", Build.CURRENT.isSnapshot()); final String nodeToRestartName = internalCluster().startNode(); final String nodeToRestartId = getNodeId(nodeToRestartName); @@ -58,7 +58,7 @@ public void testReproduceNotStartedBug() throws Exception { assertThat(getResp.getShutdownStatuses().get(0).migrationStatus().getStatus(), equalTo(COMPLETE)); } - public void testNotStartedBugOnDedicatedMaster() throws Exception { + public void testShardStatusIsCompleteOnNonDataNodes() throws Exception { assumeTrue("must be on a snapshot build of ES to run in order for the feature flag to be set", Build.CURRENT.isSnapshot()); final String nodeToShutDownName = internalCluster().startMasterOnlyNode(); internalCluster().startMasterOnlyNode(); // Just to have at least one other node From aafb1533c698629940c4540a0e086e49da4a92ed Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Thu, 12 Aug 2021 17:01:05 -0600 Subject: [PATCH 10/17] Actually start the service + add test to make sure we did --- .../xpack/shutdown/NodeShutdownShardsIT.java | 37 +++++++++++++++++++ .../xpack/shutdown/ShutdownPlugin.java | 29 +++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java index 3e504f9b939ca..e6b76ab4a8942 100644 --- a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java +++ b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java @@ -13,8 +13,10 @@ import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata; import org.elasticsearch.cluster.node.DiscoveryNode; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESIntegTestCase; +import org.elasticsearch.test.InternalTestCluster; import java.util.Arrays; import java.util.Collection; @@ -58,6 +60,41 @@ public void testShardStatusStaysCompleteAfterNodeLeaves() throws Exception { assertThat(getResp.getShutdownStatuses().get(0).migrationStatus().getStatus(), equalTo(COMPLETE)); } + public void testShardStatusStaysCompleteAfterNodeLeavesIfRegisteredWhileNodeOffline() throws Exception { + assumeTrue("must be on a snapshot build of ES to run in order for the feature flag to be set", Build.CURRENT.isSnapshot()); + final String nodeToRestartName = internalCluster().startNode(); + final String nodeToRestartId = getNodeId(nodeToRestartName); + internalCluster().startNode(); + + // Stop the node we're going to shut down and mark it as shutting down while it's offline. This checks that the cluster state + // listener is working correctly. + internalCluster().restartNode(nodeToRestartName, new InternalTestCluster.RestartCallback() { + @Override public Settings onNodeStopped(String nodeName) throws Exception { + PutShutdownNodeAction.Request putShutdownRequest = new PutShutdownNodeAction.Request( + nodeToRestartId, + SingleNodeShutdownMetadata.Type.REMOVE, + "testShardStatusStaysCompleteAfterNodeLeavesIfRegisteredWhileNodeOffline" + ); + AcknowledgedResponse putShutdownResponse = client().execute(PutShutdownNodeAction.INSTANCE, putShutdownRequest).get(); + assertTrue(putShutdownResponse.isAcknowledged()); + + return super.onNodeStopped(nodeName); + } + }); + + internalCluster().stopNode(nodeToRestartName); + + NodesInfoResponse nodes = client().admin().cluster().prepareNodesInfo().clear().get(); + assertThat(nodes.getNodes().size(), equalTo(1)); + + GetShutdownStatusAction.Response getResp = client().execute( + GetShutdownStatusAction.INSTANCE, + new GetShutdownStatusAction.Request(nodeToRestartId) + ).get(); + + assertThat(getResp.getShutdownStatuses().get(0).migrationStatus().getStatus(), equalTo(COMPLETE)); + } + public void testShardStatusIsCompleteOnNonDataNodes() throws Exception { assumeTrue("must be on a snapshot build of ES to run in order for the feature flag to be set", Build.CURRENT.isSnapshot()); final String nodeToShutDownName = internalCluster().startMasterOnlyNode(); diff --git a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownPlugin.java b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownPlugin.java index 2b796bdda060f..3346c966cef0e 100644 --- a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownPlugin.java +++ b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownPlugin.java @@ -10,19 +10,30 @@ import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.client.Client; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.node.DiscoveryNodes; +import org.elasticsearch.cluster.service.ClusterService; +import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.IndexScopedSettings; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.SettingsFilter; +import org.elasticsearch.common.xcontent.NamedXContentRegistry; +import org.elasticsearch.env.Environment; +import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.plugins.ActionPlugin; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.rest.RestController; import org.elasticsearch.rest.RestHandler; +import org.elasticsearch.script.ScriptService; +import org.elasticsearch.threadpool.ThreadPool; +import org.elasticsearch.watcher.ResourceWatcherService; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.function.Supplier; @@ -56,6 +67,24 @@ public boolean isEnabled(Settings settings) { return SHUTDOWN_FEATURE_ENABLED_FLAG_SETTING.get(settings); } + @Override public Collection createComponents( + Client client, + ClusterService clusterService, + ThreadPool threadPool, + ResourceWatcherService resourceWatcherService, + ScriptService scriptService, + NamedXContentRegistry xContentRegistry, + Environment environment, + NodeEnvironment nodeEnvironment, + NamedWriteableRegistry namedWriteableRegistry, + IndexNameExpressionResolver indexNameExpressionResolver, + Supplier repositoriesServiceSupplier) { + + ShutdownService shutdownService = new ShutdownService(clusterService); + + return Collections.singletonList(shutdownService); + } + @Override public List> getActions() { ActionHandler putShutdown = new ActionHandler<>( From e8e7914c90b4990b4c285750dfd02978e930838d Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Fri, 13 Aug 2021 10:10:47 -0600 Subject: [PATCH 11/17] ShutdownService javadoc --- .../org/elasticsearch/xpack/shutdown/ShutdownService.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownService.java b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownService.java index 560befaaae944..5534c29224901 100644 --- a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownService.java +++ b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownService.java @@ -24,6 +24,11 @@ import java.util.function.Function; import java.util.stream.Collectors; +/** + * A class that handles ongoing reactive logic related to Node Shutdown. + * + * Currently, this consists of keeping track of whether we've seen nodes which are marked for shutdown. + */ public class ShutdownService implements ClusterStateListener { private static final Logger logger = LogManager.getLogger(ShutdownService.class); From 65fcfddfc8113c9d2c0b76bbb3442f777dda8a97 Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Fri, 13 Aug 2021 10:12:54 -0600 Subject: [PATCH 12/17] Add `nodesAdded()` check --- .../org/elasticsearch/xpack/shutdown/ShutdownService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownService.java b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownService.java index 5534c29224901..d90363361f1e3 100644 --- a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownService.java +++ b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownService.java @@ -45,6 +45,12 @@ public void clusterChanged(ClusterChangedEvent event) { // Only do this if we're the current master node. return; } + + if (event.nodesAdded() == false) { + // If there's no new nodes this cluster state update, nothing to do. + return; + } + NodesShutdownMetadata eventShutdownMetadata = event.state().metadata().custom(NodesShutdownMetadata.TYPE); final Set nodesNotPreviouslySeen = eventShutdownMetadata.getAllNodeMetadataMap() .values() From 3e371facb234d77c1634a8c22f8c71c2a7a48fa0 Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Fri, 13 Aug 2021 10:15:26 -0600 Subject: [PATCH 13/17] Check both nodesNotPreviouslySeen and current known nodes in update task --- .../java/org/elasticsearch/xpack/shutdown/ShutdownService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownService.java b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownService.java index d90363361f1e3..32e52103fc9a0 100644 --- a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownService.java +++ b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownService.java @@ -70,7 +70,8 @@ public ClusterState execute(ClusterState currentState) throws Exception { .values() .stream() .map(singleNodeShutdownMetadata -> { - if (nodesNotPreviouslySeen.contains(singleNodeShutdownMetadata.getNodeId())) { + if (nodesNotPreviouslySeen.contains(singleNodeShutdownMetadata.getNodeId()) + || currentState.nodes().nodeExists(singleNodeShutdownMetadata.getNodeId())) { return SingleNodeShutdownMetadata.builder(singleNodeShutdownMetadata).setNodeSeen(true).build(); } return singleNodeShutdownMetadata; From 04957beea3f48f14670bf49ac57a4779276700c8 Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Fri, 13 Aug 2021 10:18:22 -0600 Subject: [PATCH 14/17] Check to make sure the update isn't a no-op before making a new ClusterState --- .../xpack/shutdown/ShutdownService.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownService.java b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownService.java index 32e52103fc9a0..715c7242d5bbc 100644 --- a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownService.java +++ b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownService.java @@ -64,9 +64,9 @@ public void clusterChanged(ClusterChangedEvent event) { clusterService.submitStateUpdateTask("shutdown-seen-nodes-updater", new ClusterStateUpdateTask() { @Override public ClusterState execute(ClusterState currentState) throws Exception { - NodesShutdownMetadata shutdownMetadata = currentState.metadata().custom(NodesShutdownMetadata.TYPE); + NodesShutdownMetadata currentShutdownMetadata = currentState.metadata().custom(NodesShutdownMetadata.TYPE); - final Map newShutdownMetadataMap = shutdownMetadata.getAllNodeMetadataMap() + final Map newShutdownMetadataMap = currentShutdownMetadata.getAllNodeMetadataMap() .values() .stream() .map(singleNodeShutdownMetadata -> { @@ -78,12 +78,14 @@ public ClusterState execute(ClusterState currentState) throws Exception { }) .collect(Collectors.toUnmodifiableMap(SingleNodeShutdownMetadata::getNodeId, Function.identity())); + final NodesShutdownMetadata newNodesMetadata = new NodesShutdownMetadata(newShutdownMetadataMap); + if (newNodesMetadata.equals(currentShutdownMetadata)) { + // Turns out the update was a no-op + return currentState; + } + return ClusterState.builder(currentState) - .metadata( - Metadata.builder(currentState.metadata()) - .putCustom(NodesShutdownMetadata.TYPE, new NodesShutdownMetadata(newShutdownMetadataMap)) - .build() - ) + .metadata(Metadata.builder(currentState.metadata()).putCustom(NodesShutdownMetadata.TYPE, newNodesMetadata).build()) .build(); } From 749a8215fc7e0508c554c81da72075b604da0ec9 Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Fri, 13 Aug 2021 10:27:16 -0600 Subject: [PATCH 15/17] Test javadoc --- .../xpack/shutdown/NodeShutdownShardsIT.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java index e6b76ab4a8942..89c5e401298c7 100644 --- a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java +++ b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java @@ -32,6 +32,10 @@ protected Collection> nodePlugins() { return Arrays.asList(ShutdownPlugin.class); } + /** + * Verifies that a node that's removed from the cluster with zero shards stays in the `COMPLETE` status after it leaves, rather than + * reverting to `NOT_STARTED` (this was a bug in the initial implementation). + */ public void testShardStatusStaysCompleteAfterNodeLeaves() throws Exception { assumeTrue("must be on a snapshot build of ES to run in order for the feature flag to be set", Build.CURRENT.isSnapshot()); final String nodeToRestartName = internalCluster().startNode(); @@ -60,6 +64,10 @@ public void testShardStatusStaysCompleteAfterNodeLeaves() throws Exception { assertThat(getResp.getShutdownStatuses().get(0).migrationStatus().getStatus(), equalTo(COMPLETE)); } + /** + * Similar to the previous test, but ensures that the status stays at `COMPLETE` when the node is offline when the shutdown is + * registered. This may happen if {@link ShutdownService} isn't working as expected. + */ public void testShardStatusStaysCompleteAfterNodeLeavesIfRegisteredWhileNodeOffline() throws Exception { assumeTrue("must be on a snapshot build of ES to run in order for the feature flag to be set", Build.CURRENT.isSnapshot()); final String nodeToRestartName = internalCluster().startNode(); @@ -95,6 +103,10 @@ public void testShardStatusStaysCompleteAfterNodeLeavesIfRegisteredWhileNodeOffl assertThat(getResp.getShutdownStatuses().get(0).migrationStatus().getStatus(), equalTo(COMPLETE)); } + /** + * Checks that non-data nodes that are registered for shutdown have a shard migration status of `COMPLETE` rather than `NOT_STARTED`. + * (this was a bug in the initial implementation). + */ public void testShardStatusIsCompleteOnNonDataNodes() throws Exception { assumeTrue("must be on a snapshot build of ES to run in order for the feature flag to be set", Build.CURRENT.isSnapshot()); final String nodeToShutDownName = internalCluster().startMasterOnlyNode(); From a090c7fcc6cec0cf48f327ffbbdb2ca8165513e5 Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Fri, 13 Aug 2021 10:37:08 -0600 Subject: [PATCH 16/17] spotless --- .../elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java | 3 ++- .../org/elasticsearch/xpack/shutdown/ShutdownPlugin.java | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java index 89c5e401298c7..0302083e52520 100644 --- a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java +++ b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java @@ -77,7 +77,8 @@ public void testShardStatusStaysCompleteAfterNodeLeavesIfRegisteredWhileNodeOffl // Stop the node we're going to shut down and mark it as shutting down while it's offline. This checks that the cluster state // listener is working correctly. internalCluster().restartNode(nodeToRestartName, new InternalTestCluster.RestartCallback() { - @Override public Settings onNodeStopped(String nodeName) throws Exception { + @Override + public Settings onNodeStopped(String nodeName) throws Exception { PutShutdownNodeAction.Request putShutdownRequest = new PutShutdownNodeAction.Request( nodeToRestartId, SingleNodeShutdownMetadata.Type.REMOVE, diff --git a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownPlugin.java b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownPlugin.java index 3346c966cef0e..094ee68b2e4c2 100644 --- a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownPlugin.java +++ b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownPlugin.java @@ -67,7 +67,8 @@ public boolean isEnabled(Settings settings) { return SHUTDOWN_FEATURE_ENABLED_FLAG_SETTING.get(settings); } - @Override public Collection createComponents( + @Override + public Collection createComponents( Client client, ClusterService clusterService, ThreadPool threadPool, @@ -78,7 +79,8 @@ public boolean isEnabled(Settings settings) { NodeEnvironment nodeEnvironment, NamedWriteableRegistry namedWriteableRegistry, IndexNameExpressionResolver indexNameExpressionResolver, - Supplier repositoriesServiceSupplier) { + Supplier repositoriesServiceSupplier + ) { ShutdownService shutdownService = new ShutdownService(clusterService); From 8832c421da20dfee81f43f74ed70730e876284ff Mon Sep 17 00:00:00 2001 From: Gordon Brown Date: Tue, 17 Aug 2021 16:49:20 -0600 Subject: [PATCH 17/17] ShutdownService -> NodeSeenService --- .../elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java | 2 +- .../shutdown/{ShutdownService.java => NodeSeenService.java} | 6 +++--- .../org/elasticsearch/xpack/shutdown/ShutdownPlugin.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) rename x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/{ShutdownService.java => NodeSeenService.java} (95%) diff --git a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java index c99863c527e85..91a0ecec39491 100644 --- a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java +++ b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java @@ -67,7 +67,7 @@ public void testShardStatusStaysCompleteAfterNodeLeaves() throws Exception { /** * Similar to the previous test, but ensures that the status stays at `COMPLETE` when the node is offline when the shutdown is - * registered. This may happen if {@link ShutdownService} isn't working as expected. + * registered. This may happen if {@link NodeSeenService} isn't working as expected. */ public void testShardStatusStaysCompleteAfterNodeLeavesIfRegisteredWhileNodeOffline() throws Exception { assumeTrue("must be on a snapshot build of ES to run in order for the feature flag to be set", Build.CURRENT.isSnapshot()); diff --git a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownService.java b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/NodeSeenService.java similarity index 95% rename from x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownService.java rename to x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/NodeSeenService.java index 715c7242d5bbc..5a647e5e1bad2 100644 --- a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownService.java +++ b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/NodeSeenService.java @@ -29,12 +29,12 @@ * * Currently, this consists of keeping track of whether we've seen nodes which are marked for shutdown. */ -public class ShutdownService implements ClusterStateListener { - private static final Logger logger = LogManager.getLogger(ShutdownService.class); +public class NodeSeenService implements ClusterStateListener { + private static final Logger logger = LogManager.getLogger(NodeSeenService.class); final ClusterService clusterService; - public ShutdownService(ClusterService clusterService) { + public NodeSeenService(ClusterService clusterService) { this.clusterService = clusterService; clusterService.addListener(this); } diff --git a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownPlugin.java b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownPlugin.java index 094ee68b2e4c2..5fa7da8312263 100644 --- a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownPlugin.java +++ b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownPlugin.java @@ -82,9 +82,9 @@ public Collection createComponents( Supplier repositoriesServiceSupplier ) { - ShutdownService shutdownService = new ShutdownService(clusterService); + NodeSeenService nodeSeenService = new NodeSeenService(clusterService); - return Collections.singletonList(shutdownService); + return Collections.singletonList(nodeSeenService); } @Override