Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions plugins/out_es/es.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ static int elasticsearch_error_check(struct flb_elasticsearch *ctx,
if (ret == -1) {
/* Is this an incomplete HTTP Request ? */
if (c->resp.payload_size <= 0) {
check |= FLB_ES_STATUS_IMCOMPLETE;
check |= FLB_ES_STATUS_INCOMPLETE;
return check;
}

Expand All @@ -702,7 +702,7 @@ static int elasticsearch_error_check(struct flb_elasticsearch *ctx,
flb_plg_error(ctx->ins, "Cannot unpack response to find error\n%s",
c->resp.payload);
check |= FLB_ES_STATUS_ERROR_UNPACK;
return check;
goto done;
}

root = result.data;
Expand All @@ -718,7 +718,7 @@ static int elasticsearch_error_check(struct flb_elasticsearch *ctx,
if (key.type != MSGPACK_OBJECT_STR) {
flb_plg_error(ctx->ins, "unexpected key type=%i",
key.type);
check |= FLB_ES_STATUS_INVAILD_ARGUMENT;
check |= FLB_ES_STATUS_INVALID_ARGUMENT;
goto done;
}

Expand Down Expand Up @@ -759,7 +759,7 @@ static int elasticsearch_error_check(struct flb_elasticsearch *ctx,
if (item.via.map.size != 1) {
flb_plg_error(ctx->ins, "unexpected 'item' size=%i",
item.via.map.size);
check |= FLB_ES_STATUS_INVAILD_ARGUMENT;
check |= FLB_ES_STATUS_INVALID_ARGUMENT;
goto done;
}

Expand Down Expand Up @@ -790,11 +790,11 @@ static int elasticsearch_error_check(struct flb_elasticsearch *ctx,
goto done;
}
/* Check for success responses */
if (item_val.via.i64 == 200 || item_val.via.i64 == 201) {
if ((item_val.via.i64 >= 200 && item_val.via.i64 < 300) || item_val.via.i64 == 409) {
check |= FLB_ES_STATUS_SUCCESS;
}
/* Check for errors other than version conflict (document already exists) */
if (item_val.via.i64 != 409) {
if (item_val.via.i64 >= 400 && item_val.via.i64 != 409) {
check |= FLB_ES_STATUS_ERROR;
}
}
Expand Down Expand Up @@ -955,12 +955,14 @@ static void cb_es_flush(struct flb_event_chunk *event_chunk,
* and lookup the 'error' field.
*/
ret = elasticsearch_error_check(ctx, c);
if (ret & FLB_ES_STATUS_SUCCESS) {
if (ret == FLB_ES_STATUS_SUCCESS) {
/* Only the SUCCESS flag was set => the batch was completely accepted by ElasticSearch. */
flb_plg_debug(ctx->ins, "Elasticsearch response\n%s",
c->resp.payload);
}
else {
/* we got an error */
/* Some errors were discovered while parsing the response.
* Any error that may coexist with the SUCCESS flag should cause a retry. */
if (ctx->trace_error) {
/*
* If trace_error is set, trace the actual
Expand Down
4 changes: 2 additions & 2 deletions plugins/out_es/es.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
#define FLB_ES_WRITE_OP_UPSERT "upsert"

#define FLB_ES_STATUS_SUCCESS (1 << 0)
#define FLB_ES_STATUS_IMCOMPLETE (1 << 1)
#define FLB_ES_STATUS_INCOMPLETE (1 << 1)
#define FLB_ES_STATUS_ERROR_UNPACK (1 << 2)
#define FLB_ES_STATUS_BAD_TYPE (1 << 3)
#define FLB_ES_STATUS_INVAILD_ARGUMENT (1 << 4)
#define FLB_ES_STATUS_INVALID_ARGUMENT (1 << 4)
#define FLB_ES_STATUS_BAD_RESPONSE (1 << 5)
#define FLB_ES_STATUS_DUPLICATES (1 << 6)
#define FLB_ES_STATUS_ERROR (1 << 7)
Expand Down
Loading