-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Description
I discovered that Elasticsearch handles differently the response of a common pattern: "Trigger an action that has already been triggered".
Rollup job --> start
POST _rollup/job/<job_id>/_start
When we try to start a rollup job that is already started, Elasticsearch throws a 500 Internal Server Error instead of a 400 Bad Request.
This is the error returned
status: 500,
displayName: 'InternalServerError',
message:
'[exception] Cannot start task for Rollup Job [my-job] because state was [STARTED]',
path: '/_rollup/job/my-job/_start',
query: {},
body:
{ error:
{ root_cause: [Array],
type: 'exception',
reason:
'Cannot start task for Rollup Job [my-job] because state was [STARTED]' },
status: 500 },
statusCode: 500,
Rollup job --> stop
POST _rollup/job/<job_id>/_stop
This action is idempotent. We can call it as many times as we want, we always get a
200 OK
{
stopped: true
}
Start trial
POST _xpack/license/start_trial
If we compare the above with the start trial API, we can see that it is handled differently. If we have already started the trial and we call the request again we get a 403 Forbidden
{
"acknowledged": true,
"trial_was_started": false,
"error_message": "Operation failed: Trial was already activated."
}
I think it would be nice to align the way ES handle these types of requests and their status code.
I also realize another wrong status in the Rollup API. When we try to delete a Job that has been started, we receive also a 500 Internal Server Error instead of a 400 Bad Request.
{
Internal Server Error::{
"path": "/_rollup/job/my-job",
"query": {},
"statusCode": 500,
"response": "{\"task_failures\":[{\"task_id\":1464,\"node_id\":\"38IK6IjmQAy2y2tgb7q_Nw\",\"status\":\"INTERNAL_SERVER_ERROR\",\"reason\":{\"type\":\"illegal_state_exception\",\"reason\":\"Could not delete job [my-job] because indexer state is [STARTED]. Job must be [STOPPED] before deletion.\"}}],\"acknowledged\":false}"
}