Skip to content

Commit 2c60a44

Browse files
author
elasticsearchmachine
committed
Merge remote-tracking branch 'origin/main' into lucene_snapshot
2 parents 1229f7e + 551a7d6 commit 2c60a44

File tree

9 files changed

+57
-59
lines changed

9 files changed

+57
-59
lines changed

muted-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,9 @@ tests:
422422
- class: org.elasticsearch.xpack.eql.EqlStatsIT
423423
method: testEqlRestUsage
424424
issue: https://github.com/elastic/elasticsearch/issues/114790
425+
- class: org.elasticsearch.xpack.eql.EqlRestIT
426+
method: testUnicodeChars
427+
issue: https://github.com/elastic/elasticsearch/issues/114791
425428

426429
# Examples:
427430
#

qa/ccs-unavailable-clusters/build.gradle

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
* your election, the "Elastic License 2.0", the "GNU Affero General Public
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
9-
apply plugin: 'elasticsearch.legacy-java-rest-test'
109

11-
testClusters.matching { it.name == "javaRestTest" }.configureEach {
12-
setting 'xpack.security.enabled', 'true'
13-
user username: 'admin', password: 'admin-password', role: 'superuser'
10+
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
11+
12+
apply plugin: 'elasticsearch.internal-java-rest-test'
13+
14+
15+
tasks.withType(StandaloneRestIntegTestTask) {
16+
usesDefaultDistribution()
1417
}

qa/ccs-unavailable-clusters/src/javaRestTest/java/org/elasticsearch/search/CrossClusterSearchUnavailableClusterIT.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@
3838
import org.elasticsearch.common.util.concurrent.EsExecutors;
3939
import org.elasticsearch.common.util.concurrent.ThreadContext;
4040
import org.elasticsearch.search.aggregations.InternalAggregations;
41+
import org.elasticsearch.test.cluster.ElasticsearchCluster;
4142
import org.elasticsearch.test.rest.ESRestTestCase;
4243
import org.elasticsearch.test.rest.ObjectPath;
4344
import org.elasticsearch.test.transport.MockTransportService;
4445
import org.elasticsearch.threadpool.TestThreadPool;
4546
import org.elasticsearch.threadpool.ThreadPool;
4647
import org.elasticsearch.xcontent.XContentBuilder;
4748
import org.elasticsearch.xcontent.json.JsonXContent;
49+
import org.junit.ClassRule;
4850

4951
import java.io.IOException;
5052
import java.util.Collections;
@@ -61,6 +63,14 @@ public class CrossClusterSearchUnavailableClusterIT extends ESRestTestCase {
6163

6264
private final ThreadPool threadPool = new TestThreadPool(getClass().getName());
6365

66+
@ClassRule
67+
public static ElasticsearchCluster cluster = ElasticsearchCluster.local().build();
68+
69+
@Override
70+
protected String getTestRestCluster() {
71+
return cluster.getHttpAddresses();
72+
}
73+
6474
@Override
6575
public void tearDown() throws Exception {
6676
super.tearDown();

server/src/main/java/org/elasticsearch/repositories/RepositoriesService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -937,8 +937,7 @@ private static boolean indexSettingsMatchRepositoryMetadata(IndexMetadata indexM
937937
private static RepositoryConflictException newRepositoryConflictException(String repository, String reason) {
938938
return new RepositoryConflictException(
939939
repository,
940-
"trying to modify or unregister repository that is currently used (" + reason + ')',
941-
"trying to modify or unregister repository [" + repository + "] that is currently used (" + reason + ')'
940+
"trying to modify or unregister repository that is currently used (" + reason + ')'
942941
);
943942
}
944943

server/src/main/java/org/elasticsearch/repositories/RepositoryConflictException.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import org.elasticsearch.common.io.stream.StreamInput;
1313
import org.elasticsearch.common.io.stream.StreamOutput;
14+
import org.elasticsearch.core.UpdateForV9;
1415
import org.elasticsearch.rest.RestStatus;
1516

1617
import java.io.IOException;
@@ -19,30 +20,25 @@
1920
* Repository conflict exception
2021
*/
2122
public class RepositoryConflictException extends RepositoryException {
22-
private final String backwardCompatibleMessage;
23-
24-
public RepositoryConflictException(String repository, String message, String backwardCompatibleMessage) {
23+
public RepositoryConflictException(String repository, String message) {
2524
super(repository, message);
26-
this.backwardCompatibleMessage = backwardCompatibleMessage;
2725
}
2826

2927
@Override
3028
public RestStatus status() {
3129
return RestStatus.CONFLICT;
3230
}
3331

34-
public String getBackwardCompatibleMessage() {
35-
return backwardCompatibleMessage;
36-
}
37-
32+
@UpdateForV9(owner = UpdateForV9.Owner.DISTRIBUTED_COORDINATION) // drop unneeded string from wire format
3833
public RepositoryConflictException(StreamInput in) throws IOException {
3934
super(in);
40-
this.backwardCompatibleMessage = in.readString();
35+
in.readString();
4136
}
4237

4338
@Override
39+
@UpdateForV9(owner = UpdateForV9.Owner.DISTRIBUTED_COORDINATION) // drop unneeded string from wire format
4440
protected void writeTo(StreamOutput out, Writer<Throwable> nestedExceptionsWriter) throws IOException {
4541
super.writeTo(out, nestedExceptionsWriter);
46-
out.writeString(backwardCompatibleMessage);
42+
out.writeString("");
4743
}
4844
}

server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestDeleteRepositoryAction.java

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
package org.elasticsearch.rest.action.admin.cluster;
1111

1212
import org.elasticsearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest;
13-
import org.elasticsearch.action.support.master.AcknowledgedResponse;
1413
import org.elasticsearch.client.internal.node.NodeClient;
15-
import org.elasticsearch.core.RestApiVersion;
16-
import org.elasticsearch.repositories.RepositoryConflictException;
1714
import org.elasticsearch.rest.BaseRestHandler;
1815
import org.elasticsearch.rest.RestRequest;
1916
import org.elasticsearch.rest.Scope;
@@ -45,19 +42,11 @@ public String getName() {
4542

4643
@Override
4744
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
48-
String name = request.param("repository");
49-
final var deleteRepositoryRequest = new DeleteRepositoryRequest(getMasterNodeTimeout(request), getAckTimeout(request), name);
50-
return channel -> client.admin()
51-
.cluster()
52-
.deleteRepository(
53-
deleteRepositoryRequest,
54-
new RestToXContentListener<AcknowledgedResponse>(channel).delegateResponse((delegate, err) -> {
55-
if (request.getRestApiVersion().equals(RestApiVersion.V_7) && err instanceof RepositoryConflictException) {
56-
delegate.onFailure(new IllegalStateException(((RepositoryConflictException) err).getBackwardCompatibleMessage()));
57-
} else {
58-
delegate.onFailure(err);
59-
}
60-
})
61-
);
45+
final var deleteRepositoryRequest = new DeleteRepositoryRequest(
46+
getMasterNodeTimeout(request),
47+
getAckTimeout(request),
48+
request.param("repository")
49+
);
50+
return channel -> client.admin().cluster().deleteRepository(deleteRepositoryRequest, new RestToXContentListener<>(channel));
6251
}
6352
}

server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestPutRepositoryAction.java

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
package org.elasticsearch.rest.action.admin.cluster;
1111

1212
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryRequest;
13-
import org.elasticsearch.action.support.master.AcknowledgedResponse;
1413
import org.elasticsearch.client.internal.node.NodeClient;
15-
import org.elasticsearch.core.RestApiVersion;
16-
import org.elasticsearch.repositories.RepositoryConflictException;
1714
import org.elasticsearch.rest.BaseRestHandler;
1815
import org.elasticsearch.rest.RestRequest;
1916
import org.elasticsearch.rest.Scope;
@@ -47,23 +44,15 @@ public String getName() {
4744

4845
@Override
4946
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
50-
String name = request.param("repository");
51-
final var putRepositoryRequest = new PutRepositoryRequest(getMasterNodeTimeout(request), getAckTimeout(request), name);
47+
final var putRepositoryRequest = new PutRepositoryRequest(
48+
getMasterNodeTimeout(request),
49+
getAckTimeout(request),
50+
request.param("repository")
51+
);
5252
try (XContentParser parser = request.contentParser()) {
5353
putRepositoryRequest.source(parser.mapOrdered());
5454
}
5555
putRepositoryRequest.verify(request.paramAsBoolean("verify", true));
56-
return channel -> client.admin()
57-
.cluster()
58-
.putRepository(
59-
putRepositoryRequest,
60-
new RestToXContentListener<AcknowledgedResponse>(channel).delegateResponse((delegate, err) -> {
61-
if (request.getRestApiVersion().equals(RestApiVersion.V_7) && err instanceof RepositoryConflictException) {
62-
delegate.onFailure(new IllegalStateException(((RepositoryConflictException) err).getBackwardCompatibleMessage()));
63-
} else {
64-
delegate.onFailure(err);
65-
}
66-
})
67-
);
56+
return channel -> client.admin().cluster().putRepository(putRepositoryRequest, new RestToXContentListener<>(channel));
6857
}
6958
}

x-pack/plugin/ilm/qa/multi-node/src/javaRestTest/java/org/elasticsearch/xpack/ilm/ExplainLifecycleIT.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.util.HashMap;
3535
import java.util.Locale;
3636
import java.util.Map;
37+
import java.util.concurrent.TimeUnit;
3738

3839
import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
3940
import static org.elasticsearch.xpack.TimeSeriesRestDriver.createFullPolicy;
@@ -307,14 +308,16 @@ public void testStepInfoPreservedOnAutoRetry() throws Exception {
307308

308309
assertBusy(() -> {
309310
Map<String, Object> explainIndex = explainIndex(client(), indexName);
310-
assertThat(explainIndex.get("failed_step_retry_count"), notNullValue());
311-
assertThat(explainIndex.get("previous_step_info"), notNullValue());
312-
assertThat((int) explainIndex.get("failed_step_retry_count"), greaterThan(0));
311+
var assertionMessage = "Assertion failed for the following response: " + explainIndex;
312+
assertThat(assertionMessage, explainIndex.get("failed_step_retry_count"), notNullValue());
313+
assertThat(assertionMessage, explainIndex.get("previous_step_info"), notNullValue());
314+
assertThat(assertionMessage, (int) explainIndex.get("failed_step_retry_count"), greaterThan(0));
313315
assertThat(
316+
assertionMessage,
314317
explainIndex.get("previous_step_info").toString(),
315318
containsString("rollover_alias [" + aliasName + "] does not point to index [" + indexName + "]")
316319
);
317-
});
320+
}, 30, TimeUnit.SECONDS);
318321
}
319322

320323
private void assertUnmanagedIndex(Map<String, Object> explainIndexMap) {

x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/ilm/IndexLifecycleTransition.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ static ClusterState moveClusterStateToStep(
137137
lifecycleState,
138138
newStepKey,
139139
nowSupplier,
140-
forcePhaseDefinitionRefresh
140+
forcePhaseDefinitionRefresh,
141+
true
141142
);
142143

143144
return LifecycleExecutionStateUtils.newClusterStateWithLifecycleState(state, idxMeta.getIndex(), newLifecycleState);
@@ -175,6 +176,7 @@ static ClusterState moveClusterStateToErrorStep(
175176
currentState,
176177
new Step.StepKey(currentStep.phase(), currentStep.action(), ErrorStep.NAME),
177178
nowSupplier,
179+
false,
178180
false
179181
);
180182

@@ -243,7 +245,8 @@ static ClusterState moveClusterStateToPreviouslyFailedStep(
243245
lifecycleState,
244246
nextStepKey,
245247
nowSupplier,
246-
forcePhaseDefinitionRefresh
248+
forcePhaseDefinitionRefresh,
249+
false
247250
);
248251

249252
LifecycleExecutionState.Builder retryStepState = LifecycleExecutionState.builder(nextStepState);
@@ -277,7 +280,8 @@ private static LifecycleExecutionState updateExecutionStateToStep(
277280
LifecycleExecutionState existingState,
278281
Step.StepKey newStep,
279282
LongSupplier nowSupplier,
280-
boolean forcePhaseDefinitionRefresh
283+
boolean forcePhaseDefinitionRefresh,
284+
boolean allowNullPreviousStepInfo
281285
) {
282286
Step.StepKey currentStep = Step.getCurrentStepKey(existingState);
283287
long nowAsMillis = nowSupplier.getAsLong();
@@ -289,7 +293,9 @@ private static LifecycleExecutionState updateExecutionStateToStep(
289293

290294
// clear any step info or error-related settings from the current step
291295
updatedState.setFailedStep(null);
292-
updatedState.setPreviousStepInfo(existingState.stepInfo());
296+
if (allowNullPreviousStepInfo || existingState.stepInfo() != null) {
297+
updatedState.setPreviousStepInfo(existingState.stepInfo());
298+
}
293299
updatedState.setStepInfo(null);
294300
updatedState.setIsAutoRetryableError(null);
295301
updatedState.setFailedStepRetryCount(null);
@@ -390,7 +396,7 @@ public static LifecycleExecutionState moveStateToNextActionAndUpdateCachedPhase(
390396
updatedState.setStep(nextStep.name());
391397
updatedState.setStepTime(nowAsMillis);
392398
updatedState.setFailedStep(null);
393-
updatedState.setPreviousStepInfo(existingState.stepInfo());
399+
updatedState.setPreviousStepInfo(null);
394400
updatedState.setStepInfo(null);
395401
updatedState.setIsAutoRetryableError(null);
396402
updatedState.setFailedStepRetryCount(null);

0 commit comments

Comments
 (0)