Fixes shrink action to remove single ndoe allocation (#33091)
This change fixes the shrink action so when the shrink is performed we remove the single node allocation fromt eh shard allocation filtering settings. Without this fix replicas cannot be allocated after we have performed the shrink and we cannot make progress with the rest of the shink aciton. This change also fixes a bug in the explain API where the maste node timeout was being set to null if it wasn't provided instead of using its default value causing a NPE
This commit is contained in:
parent
dfc70ddcc7
commit
fd88ab8c75
|
@ -56,6 +56,8 @@ public class ShrinkStep extends AsyncActionStep {
|
|||
.put(LifecycleSettings.LIFECYCLE_PHASE, phase)
|
||||
.put(LifecycleSettings.LIFECYCLE_ACTION, action)
|
||||
.put(LifecycleSettings.LIFECYCLE_STEP, ShrunkenIndexCheckStep.NAME) // skip source-index steps
|
||||
.put(IndexMetaData.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey() + "_name", (String) null) // need to remove the single shard
|
||||
// allocation so replicas can be allocated
|
||||
.build();
|
||||
String shrunkenIndexName = shrunkIndexPrefix + indexMetaData.getIndex().getName();
|
||||
ResizeRequest resizeRequest = new ResizeRequest(shrunkenIndexName, indexMetaData.getIndex().getName());
|
||||
|
|
|
@ -119,6 +119,7 @@ public class ShrinkStepTests extends AbstractStepTestCase<ShrinkStep> {
|
|||
.put(LifecycleSettings.LIFECYCLE_PHASE, step.getKey().getPhase())
|
||||
.put(LifecycleSettings.LIFECYCLE_ACTION, step.getKey().getAction())
|
||||
.put(LifecycleSettings.LIFECYCLE_STEP, ShrunkenIndexCheckStep.NAME)
|
||||
.put(IndexMetaData.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey() + "_name", (String) null)
|
||||
.build()));
|
||||
assertThat(request.getTargetIndexRequest().settings()
|
||||
.getAsInt(IndexMetaData.SETTING_NUMBER_OF_SHARDS, -1), equalTo(step.getNumberOfShards()));
|
||||
|
|
|
@ -37,7 +37,10 @@ public class RestExplainLifecycleAction extends BaseRestHandler {
|
|||
ExplainLifecycleRequest explainLifecycleRequest = new ExplainLifecycleRequest();
|
||||
explainLifecycleRequest.indices(indexes);
|
||||
explainLifecycleRequest.indicesOptions(IndicesOptions.fromRequest(restRequest, IndicesOptions.strictExpandOpen()));
|
||||
explainLifecycleRequest.masterNodeTimeout(restRequest.param("master_timeout"));
|
||||
String masterNodeTimeout = restRequest.param("master_timeout");
|
||||
if (masterNodeTimeout != null) {
|
||||
explainLifecycleRequest.masterNodeTimeout(masterNodeTimeout);
|
||||
}
|
||||
|
||||
return channel -> client.execute(ExplainLifecycleAction.INSTANCE, explainLifecycleRequest, new RestToXContentListener<>(channel));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue