Skip to content

Commit b20df67

Browse files
ryanohnemusedsiper
authored andcommitted
in_kubernetes_events: check http_get_response_data return val
Signed-off-by: ryanohnemus <[email protected]>
1 parent e48dddb commit b20df67

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

plugins/in_kubernetes_events/kubernetes_events.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ static bool check_event_is_filtered(struct k8s_events *ctx, msgpack_object *obj,
302302
flb_sds_t uid;
303303
uint64_t resource_version;
304304

305-
now = (time_t)(cfl_time_now() / 1000000000);
306-
if (event_time->tm.tv_sec < (now - ctx->retention_time)) {
305+
outdated = cfl_time_now() - (ctx->retention_time * 1000000000L);
306+
if (flb_time_to_nanosec(event_time) < outdated) {
307307
flb_plg_debug(ctx->ins, "Item is older than retention_time: %ld < %ld",
308308
flb_time_to_nanosec(event_time), outdated);
309309
return FLB_TRUE;
@@ -370,8 +370,8 @@ static bool check_event_is_filtered(struct k8s_events *ctx, msgpack_object *obj,
370370
}
371371

372372

373-
static int process_event_object(struct k8s_events* ctx, flb_sds_t action,
374-
msgpack_object* item)
373+
static int process_event_object(struct k8s_events *ctx, flb_sds_t action,
374+
msgpack_object *item)
375375
{
376376
int ret = -1;
377377
struct flb_time ts;
@@ -921,17 +921,21 @@ static int k8s_events_collect(struct flb_input_instance *ins,
921921
}
922922
/* NOTE: skipping any processing after streaming socket closes */
923923

924-
if (ctx->streaming_client->resp.status != 200) {
925-
flb_plg_warn(ins, "events watch failure, http_status=%d payload=%s",
926-
ctx->streaming_client->resp.status, ctx->streaming_client->resp.payload);
924+
if (ctx->streaming_client->resp.status != 200 || ret == FLB_HTTP_ERROR) {
925+
if (ret == FLB_HTTP_ERROR) {
926+
flb_plg_warn(ins, "kubernetes chunked stream error.");
927+
}
928+
else {
929+
flb_plg_warn(ins, "events watch failure, http_status=%d payload=%s",
930+
ctx->streaming_client->resp.status, ctx->streaming_client->resp.payload);
931+
}
927932

928933
flb_http_client_destroy(ctx->streaming_client);
929934
flb_upstream_conn_release(ctx->current_connection);
930935
ctx->streaming_client = NULL;
931936
ctx->current_connection = NULL;
932937
}
933938

934-
exit:
935939
pthread_mutex_unlock(&ctx->lock);
936940
FLB_INPUT_RETURN(0);
937941
}

0 commit comments

Comments
 (0)