[ML] Adjust error to make sense for FAILED as well as CLOSED jobs (elastic/x-pack-elasticsearch#888)
Previously trying to perform an operation on a FAILED job would tell you that it hadn't been opened. This was very confusing if you knew very well you'd just opened the job. Relates elastic/x-pack-elasticsearch#879 Original commit: elastic/x-pack-elasticsearch@2dbe41caaa
This commit is contained in:
parent
c335e79508
commit
72f5e92972
|
@ -472,7 +472,7 @@ public class StartDatafeedAction
|
||||||
JobState jobState = MlMetadata.getJobState(datafeed.getJobId(), tasks);
|
JobState jobState = MlMetadata.getJobState(datafeed.getJobId(), tasks);
|
||||||
if (jobState != JobState.OPENED) {
|
if (jobState != JobState.OPENED) {
|
||||||
throw ExceptionsHelper.conflictStatusException("cannot start datafeed [" + datafeedId + "] because job [" + job.getId() +
|
throw ExceptionsHelper.conflictStatusException("cannot start datafeed [" + datafeedId + "] because job [" + job.getId() +
|
||||||
"] hasn't been opened");
|
"] is not open");
|
||||||
}
|
}
|
||||||
|
|
||||||
PersistentTask<?> datafeedTask = MlMetadata.getDatafeedTask(datafeedId, tasks);
|
PersistentTask<?> datafeedTask = MlMetadata.getDatafeedTask(datafeedId, tasks);
|
||||||
|
|
|
@ -63,7 +63,7 @@ public abstract class TransportJobTaskAction<OperationTask extends Task, Request
|
||||||
PersistentTasksCustomMetaData tasks = clusterService.state().getMetaData().custom(PersistentTasksCustomMetaData.TYPE);
|
PersistentTasksCustomMetaData tasks = clusterService.state().getMetaData().custom(PersistentTasksCustomMetaData.TYPE);
|
||||||
PersistentTasksCustomMetaData.PersistentTask<?> jobTask = MlMetadata.getJobTask(jobId, tasks);
|
PersistentTasksCustomMetaData.PersistentTask<?> jobTask = MlMetadata.getJobTask(jobId, tasks);
|
||||||
if (jobTask == null || jobTask.isAssigned() == false) {
|
if (jobTask == null || jobTask.isAssigned() == false) {
|
||||||
String message = "Cannot perform requested action because job [" + jobId + "] hasn't been opened";
|
String message = "Cannot perform requested action because job [" + jobId + "] is not open";
|
||||||
listener.onFailure(ExceptionsHelper.conflictStatusException(message));
|
listener.onFailure(ExceptionsHelper.conflictStatusException(message));
|
||||||
} else {
|
} else {
|
||||||
request.setNodes(jobTask.getExecutorNode());
|
request.setNodes(jobTask.getExecutorNode());
|
||||||
|
@ -81,7 +81,7 @@ public abstract class TransportJobTaskAction<OperationTask extends Task, Request
|
||||||
} else {
|
} else {
|
||||||
logger.warn("Unexpected job state based on cluster state version [{}]", state.getVersion());
|
logger.warn("Unexpected job state based on cluster state version [{}]", state.getVersion());
|
||||||
listener.onFailure(ExceptionsHelper.conflictStatusException("Cannot perform requested action because job [" +
|
listener.onFailure(ExceptionsHelper.conflictStatusException("Cannot perform requested action because job [" +
|
||||||
request.getJobId() + "] hasn't been opened"));
|
request.getJobId() + "] is not open"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -421,7 +421,7 @@ public class MachineLearningLicensingTests extends BaseMlIntegTestCase {
|
||||||
if (invalidLicense) {
|
if (invalidLicense) {
|
||||||
// so the license expired then job closes automatically, so an error is expected:
|
// so the license expired then job closes automatically, so an error is expected:
|
||||||
Exception e = expectThrows(ElasticsearchStatusException.class, listener::actionGet);
|
Exception e = expectThrows(ElasticsearchStatusException.class, listener::actionGet);
|
||||||
assertEquals("Cannot perform requested action because job [foo] hasn't been opened", e.getMessage());
|
assertEquals("Cannot perform requested action because job [foo] is not open", e.getMessage());
|
||||||
} else {
|
} else {
|
||||||
listener.actionGet();
|
listener.actionGet();
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ public class StartDatafeedActionTests extends ESTestCase {
|
||||||
.build();
|
.build();
|
||||||
Exception e = expectThrows(ElasticsearchStatusException.class,
|
Exception e = expectThrows(ElasticsearchStatusException.class,
|
||||||
() -> StartDatafeedAction.validate("foo-datafeed", mlMetadata2, tasks));
|
() -> StartDatafeedAction.validate("foo-datafeed", mlMetadata2, tasks));
|
||||||
assertThat(e.getMessage(), equalTo("cannot start datafeed [foo-datafeed] because job [job_id] hasn't been opened"));
|
assertThat(e.getMessage(), equalTo("cannot start datafeed [foo-datafeed] because job [job_id] is not open"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testValidate_dataFeedAlreadyStarted() {
|
public void testValidate_dataFeedAlreadyStarted() {
|
||||||
|
|
|
@ -84,7 +84,7 @@ public class MlRestTestStateCleaner {
|
||||||
logger.error("Got status code " + statusCode + " when closing job " + jobId);
|
logger.error("Got status code " + statusCode + " when closing job " + jobId);
|
||||||
}
|
}
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
if (e1.getMessage().contains("because job [" + jobId + "] hasn't been opened")) {
|
if (e1.getMessage().contains("because job [" + jobId + "] is not open")) {
|
||||||
logger.debug("job [" + jobId + "] has already been closed", e1);
|
logger.debug("job [" + jobId + "] has already been closed", e1);
|
||||||
} else {
|
} else {
|
||||||
logger.warn("failed to close job [" + jobId + "]. Forcing closed", e1);
|
logger.warn("failed to close job [" + jobId + "]. Forcing closed", e1);
|
||||||
|
|
|
@ -293,7 +293,7 @@ public abstract class BaseMlIntegTestCase extends ESIntegTestCase {
|
||||||
client.execute(CloseJobAction.INSTANCE, closeRequest).get();
|
client.execute(CloseJobAction.INSTANCE, closeRequest).get();
|
||||||
assertTrue(response.isClosed());
|
assertTrue(response.isClosed());
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
if (e1.getMessage().contains("because job [" + jobId + "] hasn't been opened")) {
|
if (e1.getMessage().contains("because job [" + jobId + "] is not open")) {
|
||||||
logger.debug("job [" + jobId + "] has already been closed", e1);
|
logger.debug("job [" + jobId + "] has already been closed", e1);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -84,7 +84,7 @@ public class MlRestTestStateCleaner {
|
||||||
logger.error("Got status code " + statusCode + " when closing job " + jobId);
|
logger.error("Got status code " + statusCode + " when closing job " + jobId);
|
||||||
}
|
}
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
if (e1.getMessage().contains("because job [" + jobId + "] hasn't been opened")) {
|
if (e1.getMessage().contains("because job [" + jobId + "] is not open")) {
|
||||||
logger.debug("job [" + jobId + "] has already been closed", e1);
|
logger.debug("job [" + jobId + "] has already been closed", e1);
|
||||||
} else {
|
} else {
|
||||||
logger.warn("failed to close job [" + jobId + "]. Forcing closed", e1);
|
logger.warn("failed to close job [" + jobId + "]. Forcing closed", e1);
|
||||||
|
|
Loading…
Reference in New Issue