Skip to content

Commit

Permalink
debug exclude namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
AdheipSingh committed Dec 4, 2024
1 parent 22a23ef commit 1358a85
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 33 deletions.
74 changes: 42 additions & 32 deletions plugins/out_parseable/parseable.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,26 @@ static void cb_parseable_flush(struct flb_event_chunk *event_chunk,
flb_plg_info(ctx->ins, "EN: %s", ctx->p_exclude_namespaces);


if (mk_list_is_empty(&ctx->p_exclude_namespaces)) {
flb_plg_info(ctx->ins, "No exclude namespaces configured.");
} else {
struct mk_list *head;
struct flb_slist_entry *entry;
mk_list_foreach(head, &ctx->p_exclude_namespaces) {
struct mk_list *head;
struct flb_slist_entry *entry;

if (ctx->p_exclude_namespaces) {
mk_list_foreach(head, ctx->p_exclude_namespaces) {
entry = mk_list_entry(head, struct flb_slist_entry, _head);
flb_plg_info(ctx->ins, "Exclude namespace: %s", entry->str);
}
}
}

// if (mk_list_is_empty(&ctx->p_exclude_namespaces)) {
// flb_plg_info(ctx->ins, "No exclude namespaces configured.");
// } else {
// struct mk_list *head;
// struct flb_slist_entry *entry;
// mk_list_foreach(head, &ctx->p_exclude_namespaces) {
// entry = mk_list_entry(head, struct flb_slist_entry, _head);
// flb_plg_info(ctx->ins, "Exclude namespace: %s", entry->str);
// }
// }

flb_sds_t namespace_name = flb_sds_create_size(256); // Dynamic string
if (body_copy != NULL) {
Expand All @@ -147,35 +157,35 @@ static void cb_parseable_flush(struct flb_event_chunk *event_chunk,
// Debug: Print the extracted namespace name
flb_plg_info(ctx->ins, "Extracted namespace_name: %s", namespace_name);

// Exclusion logic (revised)
if (!mk_list_is_empty(&ctx->p_exclude_namespaces)) {
flb_plg_info(ctx->ins, "Checking exclude namespaces...");
// // Exclusion logic (revised)
// if (!mk_list_is_empty(&ctx->p_exclude_namespaces)) {
// flb_plg_info(ctx->ins, "Checking exclude namespaces...");

struct mk_list *head;
struct flb_slist_entry *entry;
mk_list_foreach(head, &ctx->p_exclude_namespaces) {
entry = mk_list_entry(head, struct flb_slist_entry, _head);
// struct mk_list *head;
// struct flb_slist_entry *entry;
// mk_list_foreach(head, &ctx->p_exclude_namespaces) {
// entry = mk_list_entry(head, struct flb_slist_entry, _head);

// Debug: Print each exclude namespace in the list
flb_plg_info(ctx->ins, "Checking against exclude namespace: %s", entry->str);
// // Debug: Print each exclude namespace in the list
// flb_plg_info(ctx->ins, "Checking against exclude namespace: %s", entry->str);

if (flb_sds_cmp(entry->str, namespace_name, flb_sds_len(namespace_name)) == 0) {
flb_plg_info(ctx->ins, "Skipping excluded namespace: %s", namespace_name);
// if (flb_sds_cmp(entry->str, namespace_name, flb_sds_len(namespace_name)) == 0) {
// flb_plg_info(ctx->ins, "Skipping excluded namespace: %s", namespace_name);

// Cleanup
flb_sds_destroy(namespace_name);
flb_sds_destroy(body);
flb_sds_destroy(body_copy);
msgpack_unpacked_destroy(&result);
// // Cleanup
// flb_sds_destroy(namespace_name);
// flb_sds_destroy(body);
// flb_sds_destroy(body_copy);
// msgpack_unpacked_destroy(&result);

// Skip sending the HTTP request
FLB_OUTPUT_RETURN(FLB_OK);
}
}
} else {
// Debug: List of exclude namespaces is empty
flb_plg_info(ctx->ins, "No exclude namespaces configured.");
}
// // Skip sending the HTTP request
// FLB_OUTPUT_RETURN(FLB_OK);
// }
// }
// } else {
// // Debug: List of exclude namespaces is empty
// flb_plg_info(ctx->ins, "No exclude namespaces configured.");
// }
}
} else {
// Debug: Could not find the namespace_name in body_copy
Expand Down Expand Up @@ -308,7 +318,7 @@ static struct flb_config_map config_map[] = {
"The port on the host to send logs to."
},
{
FLB_CONFIG_MAP_SLIST, "P_Exclude_Namespaces", NULL,
FLB_CONFIG_MAP_CLIST, "P_Exclude_Namespaces", NULL,
0, FLB_TRUE, offsetof(struct flb_out_parseable, p_exclude_namespaces),
"A space-separated list of Kubernetes namespaces to exclude from log forwarding."
},
Expand Down
2 changes: 1 addition & 1 deletion plugins/out_parseable/parseable.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct flb_out_parseable {
flb_sds_t p_username;
flb_sds_t p_password;
flb_sds_t p_stream;
struct mk_list p_exclude_namespaces; // Use mk_list for namespace exclusion
struct mk_list *p_exclude_namespaces; // Use mk_list for namespace exclusion
struct flb_upstream *upstream;
struct flb_output_instance *ins;
};
Expand Down

0 comments on commit 1358a85

Please sign in to comment.