From bed4933aff5df050eae570e3f4407f953e8021fe Mon Sep 17 00:00:00 2001 From: ryanohnemus Date: Tue, 2 Jan 2024 16:34:14 -0600 Subject: [PATCH] filter_kubernetes: make pod meta fetching optional now that you can fetch namespace labels/annotations OR pod labels/annotations, do not attempt to fetch pod labels/annotations if neither of them are requested via config re-pushing via force to kick of PR checks. Signed-off-by: ryanohnemus --- plugins/filter_kubernetes/kube_meta.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/filter_kubernetes/kube_meta.c b/plugins/filter_kubernetes/kube_meta.c index f296d07c60d..a85469c43c7 100644 --- a/plugins/filter_kubernetes/kube_meta.c +++ b/plugins/filter_kubernetes/kube_meta.c @@ -2046,16 +2046,18 @@ int flb_kube_meta_get(struct flb_kube *ctx, ) { int ret_namespace_meta = -1; - int ret_pod_meta; + int ret_pod_meta = -1; if(ctx->namespace_labels == FLB_TRUE || ctx->namespace_annotations == FLB_TRUE) { ret_namespace_meta = flb_kube_namespace_meta_get(ctx, tag, tag_len, data, data_size, namespace_out_buf, namespace_out_size, namespace_meta); } - ret_pod_meta = flb_kube_pod_meta_get(ctx, tag, tag_len, data, data_size, - out_buf, out_size, meta, props); - + if(ctx->labels == FLB_TRUE || ctx->annotations == FLB_TRUE) { + ret_pod_meta = flb_kube_pod_meta_get(ctx, tag, tag_len, data, data_size, + out_buf, out_size, meta, props); + } + // If we get metadata from either namespace or pod info, return success if( ret_pod_meta == 0 || ret_namespace_meta == 0) { return 0;