From d2e01ad6da9b8294335fa142e3bfc3f453786a85 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Mon, 24 Jun 2024 13:05:12 -0600 Subject: [PATCH] processor_content_modifier: logs: do not fail if keys are not found Signed-off-by: Eduardo Silva --- plugins/processor_content_modifier/cm_logs.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugins/processor_content_modifier/cm_logs.c b/plugins/processor_content_modifier/cm_logs.c index 8a73088ef78..0f20d124bad 100644 --- a/plugins/processor_content_modifier/cm_logs.c +++ b/plugins/processor_content_modifier/cm_logs.c @@ -404,7 +404,7 @@ static int run_action_insert(struct content_modifier_ctx *ctx, ret = cfl_kvlist_insert_string_s(kvlist, key, cfl_sds_len(key), value, cfl_sds_len(value), CFL_FALSE); if (ret != 0) { - printf("Failed to insert key: %s\n", key); + flb_plg_debug(ctx->ins, "[action: insert] failed to insert key: %s", key); return -1; } return 0; @@ -451,7 +451,10 @@ static int run_action_delete(struct content_modifier_ctx *ctx, return 0; } - return -1; + flb_plg_debug(ctx->ins, "[action: delete] key '%s' not found", key); + + /* if the kvpair was not found, it's ok, we return zero */ + return 0; } static int run_action_rename(struct content_modifier_ctx *ctx, @@ -465,7 +468,8 @@ static int run_action_rename(struct content_modifier_ctx *ctx, /* if the kv pair already exists, remove it from the list */ kvpair = cfl_object_kvpair_get(obj, key); if (!kvpair) { - return -1; + flb_plg_debug(ctx->ins, "[action: rename] key '%s' not found", key); + return 0; } tmp = kvpair->key;