Skip to content

Commit

Permalink
in_kubernetes_events: fix end of chunked stream deadlock
Browse files Browse the repository at this point in the history
Signed-off-by: ryanohnemus <[email protected]>
  • Loading branch information
ryanohnemus committed Aug 1, 2024
1 parent 57c04a5 commit c9bf18c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plugins/in_kubernetes_events/kubernetes_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,7 @@ static int k8s_events_collect(struct flb_input_instance *ins,
}

if (check_and_init_stream(ctx) == FLB_FALSE) {
pthread_mutex_unlock(&ctx->lock);
FLB_INPUT_RETURN(0);
}

Expand All @@ -921,15 +922,19 @@ static int k8s_events_collect(struct flb_input_instance *ins,
}
/* NOTE: skipping any processing after streaming socket closes */

if (ctx->streaming_client->resp.status != 200 || ret == FLB_HTTP_ERROR) {
if (ctx->streaming_client->resp.status != 200 || ret == FLB_HTTP_ERROR || ret == FLB_HTTP_OK) {
if (ret == FLB_HTTP_ERROR) {
flb_plg_warn(ins, "kubernetes chunked stream error.");
}
else if (ret == FLB_HTTP_OK) {
flb_plg_info(ins, "kubernetes stream closed by api server. Reconnect will happen on next interval.");
}
else {
flb_plg_warn(ins, "events watch failure, http_status=%d payload=%s",
ctx->streaming_client->resp.status, ctx->streaming_client->resp.payload);
}

flb_plg_info(ins, "kubernetes stream disconnected, ret=%d", ret);
flb_http_client_destroy(ctx->streaming_client);
flb_upstream_conn_release(ctx->current_connection);
ctx->streaming_client = NULL;
Expand Down

0 comments on commit c9bf18c

Please sign in to comment.