[ML] Improve error on get calendar when ml-meta index is missing (elastic/x-pack-elasticsearch#3576)

Relates elastic/x-pack-elasticsearch#3016

Original commit: elastic/x-pack-elasticsearch@bc60a0cb72
This commit is contained in:
Dimitris Athanasiou 2018-01-16 11:00:07 +00:00 committed by GitHub
parent ac2884f034
commit 2350b85507
3 changed files with 14 additions and 1 deletions

View File

@ -51,6 +51,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
@ -1204,7 +1205,11 @@ public class JobProvider {
@Override
public void onFailure(Exception e) {
listener.onFailure(e);
if (e instanceof IndexNotFoundException) {
listener.onFailure(new ResourceNotFoundException("No calendar with id [" + calendarId + "]"));
} else {
listener.onFailure(e);
}
}
},
client::get);

View File

@ -92,6 +92,13 @@
"job_ids": ["cal-job", "unknown-job"]
}
---
"Test get calendar given missing":
- do:
catch: /No calendar with id \[unknown\]/
xpack.ml.get_calendars:
calendar_id: "unknown"
---
"Test PageParams":
- do:

View File

@ -20,6 +20,7 @@ integTestRunner {
'ml/ml_classic_analyze/Test analyze API with an analyzer that does what we used to do in native code',
// Remove tests that are expected to throw an exception, because we cannot then
// know whether to expect an authorization exception or a validation exception
'ml/calendar_crud/Test get calendar given missing',
'ml/calendar_crud/Test cannot create calendar with name _all',
'ml/calendar_crud/Test PageParams with ID is invalid',
'ml/calendar_crud/Test post calendar events given empty events',