Skip to content

Commit 479ebd1

Browse files
authored
[ML][Transforms] remove force flag from _start (#46414)
* [ML][Transforms] remove `force` flag from _start * fixing expected error message
1 parent 3e25db2 commit 479ebd1

File tree

16 files changed

+58
-397
lines changed

16 files changed

+58
-397
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/XPackClientPlugin.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@
198198
import org.elasticsearch.xpack.core.transform.action.PreviewTransformAction;
199199
import org.elasticsearch.xpack.core.transform.action.PutTransformAction;
200200
import org.elasticsearch.xpack.core.transform.action.StartTransformAction;
201-
import org.elasticsearch.xpack.core.transform.action.StartTransformTaskAction;
202201
import org.elasticsearch.xpack.core.transform.action.StopTransformAction;
203202
import org.elasticsearch.xpack.core.transform.transforms.Transform;
204203
import org.elasticsearch.xpack.core.transform.transforms.TransformState;
@@ -389,7 +388,6 @@ public List<ActionType<? extends ActionResponse>> getClientActions() {
389388
// Data Frame
390389
PutTransformAction.INSTANCE,
391390
StartTransformAction.INSTANCE,
392-
StartTransformTaskAction.INSTANCE,
393391
StopTransformAction.INSTANCE,
394392
DeleteTransformAction.INSTANCE,
395393
GetTransformsAction.INSTANCE,

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/TransformMessages.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class TransformMessages {
3636
" Use force stop to stop the data frame transform.";
3737
public static final String DATA_FRAME_CANNOT_START_FAILED_TRANSFORM =
3838
"Unable to start data frame transform [{0}] as it is in a failed state with failure: [{1}]. " +
39-
"Use force start to restart data frame transform once error is resolved.";
39+
"Use force stop and then restart the data frame transform once error is resolved.";
4040

4141
public static final String FAILED_TO_CREATE_DESTINATION_INDEX = "Could not create destination index [{0}] for transform [{1}]";
4242
public static final String FAILED_TO_RELOAD_TRANSFORM_CONFIGURATION =

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/action/StartTransformAction.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
package org.elasticsearch.xpack.core.transform.action;
88

9+
import org.elasticsearch.Version;
910
import org.elasticsearch.action.ActionRequestValidationException;
1011
import org.elasticsearch.action.ActionType;
1112
import org.elasticsearch.action.support.master.AcknowledgedRequest;
@@ -33,32 +34,30 @@ private StartTransformAction() {
3334
public static class Request extends AcknowledgedRequest<Request> {
3435

3536
private final String id;
36-
private final boolean force;
3737

38-
public Request(String id, boolean force) {
38+
public Request(String id) {
3939
this.id = ExceptionsHelper.requireNonNull(id, TransformField.ID.getPreferredName());
40-
this.force = force;
4140
}
4241

4342
public Request(StreamInput in) throws IOException {
4443
super(in);
4544
id = in.readString();
46-
force = in.readBoolean();
45+
if(in.getVersion().before(Version.V_8_0_0)) {
46+
in.readBoolean();
47+
}
4748
}
4849

4950
public String getId() {
5051
return id;
5152
}
5253

53-
public boolean isForce() {
54-
return force;
55-
}
56-
5754
@Override
5855
public void writeTo(StreamOutput out) throws IOException {
5956
super.writeTo(out);
6057
out.writeString(id);
61-
out.writeBoolean(force);
58+
if(out.getVersion().before(Version.V_8_0_0)) {
59+
out.writeBoolean(false);
60+
}
6261
}
6362

6463
@Override

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/action/StartTransformTaskAction.java

Lines changed: 0 additions & 152 deletions
This file was deleted.

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/action/StartTransformActionRequestTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
public class StartTransformActionRequestTests extends AbstractWireSerializingTestCase<Request> {
1414
@Override
1515
protected Request createTestInstance() {
16-
return new Request(randomAlphaOfLengthBetween(1, 20), randomBoolean());
16+
return new Request(randomAlphaOfLengthBetween(1, 20));
1717
}
1818

1919
@Override

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/action/StartTransformTaskActionRequestTests.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/action/StartTransformTaskActionResponseTests.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

x-pack/plugin/src/test/resources/rest-api-spec/test/data_frame/transforms_start_stop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ teardown:
6262
- match: { acknowledged: true }
6363

6464
- do:
65-
catch: /Unable to start data frame transform \[airline-transform-start-stop\] as it is in state \[STARTED\]/
65+
catch: /Cannot start transform \[airline-transform-start-stop\] as it is already started/
6666
data_frame.start_data_frame_transform:
6767
transform_id: "airline-transform-start-stop"
6868

x-pack/plugin/transform/qa/single-node-tests/src/test/java/org/elasticsearch/xpack/dataframe/integration/DataFrameRestTestCase.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,13 @@ protected void createPivotReviewsTransform(String transformId, String dataFrameI
224224
assertThat(createDataframeTransformResponse.get("acknowledged"), equalTo(Boolean.TRUE));
225225
}
226226

227-
protected void startDataframeTransform(String transformId, boolean force) throws IOException {
228-
startDataframeTransform(transformId, force, null);
227+
protected void startDataframeTransform(String transformId) throws IOException {
228+
startDataframeTransform(transformId, null);
229229
}
230230

231-
protected void startDataframeTransform(String transformId, boolean force, String authHeader, String... warnings) throws IOException {
231+
protected void startDataframeTransform(String transformId, String authHeader, String... warnings) throws IOException {
232232
// start the transform
233233
final Request startTransformRequest = createRequestWithAuth("POST", DATAFRAME_ENDPOINT + transformId + "/_start", authHeader);
234-
startTransformRequest.addParameter(TransformField.FORCE.getPreferredName(), Boolean.toString(force));
235234
if (warnings.length > 0) {
236235
startTransformRequest.setOptions(expectWarnings(warnings));
237236
}
@@ -259,7 +258,7 @@ protected void startAndWaitForTransform(String transformId, String dataFrameInde
259258
protected void startAndWaitForTransform(String transformId, String dataFrameIndex,
260259
String authHeader, String... warnings) throws Exception {
261260
// start the transform
262-
startDataframeTransform(transformId, false, authHeader, warnings);
261+
startDataframeTransform(transformId, authHeader, warnings);
263262
assertTrue(indexExists(dataFrameIndex));
264263
// wait until the dataframe has been created and all data is available
265264
waitForDataFrameCheckpoint(transformId);
@@ -279,7 +278,7 @@ protected void startAndWaitForContinuousTransform(String transformId,
279278
String authHeader,
280279
long checkpoint) throws Exception {
281280
// start the transform
282-
startDataframeTransform(transformId, false, authHeader, new String[0]);
281+
startDataframeTransform(transformId, authHeader, new String[0]);
283282
assertTrue(indexExists(dataFrameIndex));
284283
// wait until the dataframe has been created and all data is available
285284
waitForDataFrameCheckpoint(transformId, checkpoint);

x-pack/plugin/transform/qa/single-node-tests/src/test/java/org/elasticsearch/xpack/dataframe/integration/DataFrameTaskFailedStateIT.java

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
import static org.hamcrest.CoreMatchers.is;
2929
import static org.hamcrest.CoreMatchers.nullValue;
3030
import static org.hamcrest.Matchers.equalTo;
31-
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
32-
import static org.hamcrest.Matchers.oneOf;
3331

3432
public class DataFrameTaskFailedStateIT extends DataFrameRestTestCase {
3533

@@ -65,7 +63,7 @@ public void testForceStopFailedTransform() throws Exception {
6563
createDestinationIndexWithBadMapping(dataFrameIndex);
6664
createContinuousPivotReviewsTransform(transformId, dataFrameIndex, null);
6765
failureTransforms.add(transformId);
68-
startDataframeTransform(transformId, false);
66+
startDataframeTransform(transformId);
6967
awaitState(transformId, TransformStats.State.FAILED);
7068
Map<?, ?> fullState = getDataFrameState(transformId);
7169
final String failureReason = "task encountered more than 0 failures; latest failure: " +
@@ -89,14 +87,14 @@ public void testForceStopFailedTransform() throws Exception {
8987
assertThat(XContentMapValues.extractValue("reason", fullState), is(nullValue()));
9088
}
9189

92-
public void testForceStartFailedTransform() throws Exception {
90+
public void testStartFailedTransform() throws Exception {
9391
String transformId = "test-force-start-failed-transform";
9492
createReviewsIndex(REVIEWS_INDEX_NAME, 10);
9593
String dataFrameIndex = "failure_pivot_reviews";
9694
createDestinationIndexWithBadMapping(dataFrameIndex);
9795
createContinuousPivotReviewsTransform(transformId, dataFrameIndex, null);
9896
failureTransforms.add(transformId);
99-
startDataframeTransform(transformId, false);
97+
startDataframeTransform(transformId);
10098
awaitState(transformId, TransformStats.State.FAILED);
10199
Map<?, ?> fullState = getDataFrameState(transformId);
102100
final String failureReason = "task encountered more than 0 failures; latest failure: " +
@@ -106,26 +104,15 @@ public void testForceStartFailedTransform() throws Exception {
106104

107105
final String expectedFailure = "Unable to start data frame transform [test-force-start-failed-transform] " +
108106
"as it is in a failed state with failure: [" + failureReason +
109-
"]. Use force start to restart data frame transform once error is resolved.";
107+
"]. Use force stop and then restart the data frame transform once error is resolved.";
110108
// Verify that we cannot start the transform when the task is in a failed state
111109
assertBusy(() -> {
112-
ResponseException ex = expectThrows(ResponseException.class, () -> startDataframeTransform(transformId, false));
110+
ResponseException ex = expectThrows(ResponseException.class, () -> startDataframeTransform(transformId));
113111
assertThat(ex.getResponse().getStatusLine().getStatusCode(), equalTo(RestStatus.CONFLICT.getStatus()));
114112
assertThat(XContentMapValues.extractValue("error.reason", entityAsMap(ex.getResponse())),
115113
equalTo(expectedFailure));
116114
}, 60, TimeUnit.SECONDS);
117115

118-
// Correct the failure by deleting the destination index
119-
deleteIndex(dataFrameIndex);
120-
// Force start the data frame to indicate failure correction
121-
startDataframeTransform(transformId, true);
122-
123-
// Verify that we have started and that our reason is cleared
124-
fullState = getDataFrameState(transformId);
125-
assertThat(XContentMapValues.extractValue("reason", fullState), is(nullValue()));
126-
assertThat(XContentMapValues.extractValue("state", fullState), oneOf("started", "indexing"));
127-
assertThat((Integer)XContentMapValues.extractValue("stats.index_failures", fullState), greaterThanOrEqualTo(1));
128-
129116
stopDataFrameTransform(transformId, true);
130117
}
131118

0 commit comments

Comments
 (0)