Commit Graph

17 Commits

Author SHA1 Message Date
Gordon Brown 2397b4496b
Make PUT shutdown API idempotent (#75161)
This PR makes the PUT shutdown API idempotent, as well as allowing
switching from shutdown types.

Co-authored-by: Lee Hinman <dakrone@users.noreply.github.com>
2021-07-12 11:09:11 -06:00
Gordon Brown 733a4d6709
Clean up Node Shutdown API responses (#74523)
This commit cleans up a few issues with the Node Shutdown API, specifically:
- GET'ing the status of a node that's registered for shutdown, but not in the cluster, now produces a useful response instead of an NPE.
- The explanation of the `STALLED` status now calls out that the Allocation Explain API should be used on the given shard in particular. We may handle this differently soon, but this improves things for now.
- DELETE'ing a non-existent shutdown request now returns HTTP code 404 instead of 400.
2021-06-24 10:52:47 -06:00
Lee Hinman b566abc8f4
Convert node shutdown system property feature flag to setting (#74267)
This converts the system property feature flag 'es.shutdown_feature_flag_enabled' to a regular
non-dynamic node setting. This setting can only be set to 'true' on a snapshot build of
Elasticsearch (not a release build).

Relates to #70338
2021-06-22 12:08:33 -06:00
Gordon Brown 335266c59d
Expose shard migration status in Node Shutdown Status API (#73873)
This commit modifies the Node Shutdown Status API to include information about the number of shards left to migrate off of the node in question, as well as checking if shard migration is stalled.

"Stalled" is defined as no shards currently relocating off the node, and at least one shard on the node which cannot move per current allocation deciders.

Relates #70338
2021-06-17 12:47:52 -06:00
Rory Hunter a5d2251064
Order imports when reformatting (#74059)
Change the formatter config to sort / order imports, and reformat the
codebase. We already had a config file for Eclipse users, so Spotless now
uses that.

The "Eclipse Code Formatter" plugin ought to be able to use this file as
well for import ordering, but in my experiments the results were poor.
Instead, use IntelliJ's `.editorconfig` support to configure import
ordering.

I've also added a config file for the formatter plugin.

Other changes:
   * I've quietly enabled the `toggleOnOff` option for Spotless. It was
     already possible to disable formatting for sections using the markers
     for docs snippets, so enabling this option just accepts this reality
     and makes it possible via `formatter:off` and `formatter:on` without
     the restrictions around line length. It should still only be used as
     a very last resort and with good reason.
   * I've removed mention of the `paddedCell` option from the contributing
     guide, since I haven't had to use that option for a very long time. I
     moved the docs to the spotless config.
2021-06-16 09:22:22 +01:00
Ryan Ernst 63012c8a40
Move ParseField to o.e.c.xcontent (#73923)
ParseField is part of the x-content lib, yet it doesn't exist under the
same root package as the rest of the lib. This commit moves the class to
the appropriate package.

relates #73784
2021-06-08 13:32:14 -07:00
Lee Hinman 2bf2bdddad
Make ILM aware of node shutdown (#73690)
This commit makes ILM aware of different parts of the node shutdown lifecycle. It consists are two
main parts, reacting to the state during execution, and signaling the status of shutdown from ILM.

Reacting to shutdown state
ILM now considers nodes that are going to be shut down when deciding which node to assign for the
shrink action. It uses the `NodeShutdownAllocationDecider` within the `SetSingleNodeAllocateStep` to
not assign shards to a node that will be removed. If an index is already past this step and waiting
for allocation, this commit adds an `isCompletable` method to the
`ClusterStateWaitUntilThresholdStep` so that an allocation that cannot happen can be rewound and
retried on another (non-shutdown) node.

Signaling shutdown status
This commit introduces the `PluginShutdownService` which deals with `ShutdownAwarePlugin` classes.
This class is used to signal shutdowns to plugins, and also to gather the status of a shutdown from
these plugins. ILM implements this `ShutdownAwarePlugin` to signal if an index is in a step that is
unsafe, such as the actual shrink step, so that shutdown will wait until after the allocation rules
have been removed by ILM.

This commit also hooks up the get shutdown API response to consider the statuses of its parts (see
`SingleNodeShutdownMetadata.Status#combine`) when creating a response.

Relates to #70338
2021-06-07 08:39:15 -06:00
Gordon Brown 5fe5b5339e
Trigger a reroute after registering a node for removal (#73449)
The cluster will not automatically react to the node shutdown being
registered unless we notify it that something has changed that may
require a change in shard allocation. This commit modifies the Put
and Delete Shutdown actions to invoke a reroute after the cluster 
state has been updated, as well as an integration test to verify that
shards quickly move away from nodes which are shutting down for
removal.
2021-06-01 13:50:49 -06:00
Rene Groeschke e609e07cfe
Remove internal build logic from public build tool plugins (#72470)
Extract usage of internal API from TestClustersPlugin and PluginBuildPlugin and related plugins and build logic

This includes a refactoring of ElasticsearchDistribution to handle types
better in a way we can differentiate between supported Elasticsearch
Distribution types supported in TestCkustersPlugin and types only supported
in internal plugins.

It also introduces a set of internal versions of public plugins.

As part of this we also generate the plugin descriptors now.

As a follow up on this we can actually move these public used classes into 
an extra project (declared as included build)

We keep LoggedExec and VersionProperties effectively public And workaround for RestTestBase
2021-05-06 14:02:35 +02:00
Gordon Brown 9ce7a5a80b
Clean up Node Shutdown metadata in test cleanup (#72726)
This commit ensures that node shutdown metadata is cleaned up between
tests, as it causes unrelated tests to fail if a test leaves node
shutdown metadata in place.
2021-05-05 10:44:57 -06:00
Lee Hinman 3f6ad3e3d4
Move shutdown component status out into separate classes (#72653)
Originally these were stored in the cluster state using a single class, however, they will need to
be different objects without common parts, and they will be calculated on the fly rather than
persisted into cluster state.

This removes the NodeShutdownComponentStatus class, as its no longer needed.

Relates to #70338
2021-05-03 20:48:37 -06:00
Gordon Brown ac402e6da4
Mute NodeShutdownIT.testAllocationPreventedForRemoval (#72590) 2021-04-30 17:32:38 -06:00
Gordon Brown f0c227d1bd
Add an allocation decider to prevent allocating shards to nodes which are preparing for shutdown (#71658)
This PR adds an allocation decider which uses the metadata managed by the Node Shutdown API to prevent shards from being allocated to nodes which are preparing to be removed from the cluster.

Additionally, shards will not be auto-expanded to nodes which are preparing to restart, instead waiting until after the restart is complete to expand the shard replication.
2021-04-30 14:42:09 -06:00
Lee Hinman 0f50800ecb
Don't assign persistent tasks to nodes shutting down (#72260)
This commit changes the `PersistentTasksClusterService` to limit nodes for a task to a subset of
nodes (candidates) that are not currently shutting down.

It does not yet cancel tasks that may already be running on the nodes that are shut down, that will
be added in a subsequent request.

Relates to #70338
2021-04-28 14:00:57 -06:00
Lyudmila Fokina 3b0b7941ae
Warn users if security is implicitly disabled (#70114)
* Warn users if security is implicitly disabled

Elasticsearch has security features implicitly disabled by default for
Basic and Trial licenses, unless explicitly set in the configuration
file.
This may be good for onboarding, but it also lead to unintended insecure
 clusters.
 This change introduces clear warnings when security features are
 implicitly disabled.
 - a warning header in each REST response if security is implicitly
 disabled;
 - a log message during cluster boot.
2021-04-13 18:33:41 +02:00
Gordon Brown f9d4991b8b
Integrate Node Shutdown API with cluster metadata (#71162)
This commit hooks up the Node Shutdown API to the Node Shutdown cluster
metadata, so using the API will result in the appropriate writes to the
cluster state.
2021-04-06 11:15:34 -06:00
Lee Hinman 5764a188a9
Add REST scaffolding for node shutdown API (#70697)
This commit adds the rest endpoints for the node shutdown API. These APIs are behind the
`es.shutdown_feature_flag_enabled` feature flag for now, as development is ongoing.

Currently these APIs do not do anything, returning immediately. We plan to implement them for real
in subsequent work.

Relates to #70338
2021-03-23 15:31:38 -06:00