From 2fe0898bc12b572d5c7845d65306f1a356426380 Mon Sep 17 00:00:00 2001 From: Melissa Kilby Date: Fri, 15 Dec 2023 18:15:47 +0000 Subject: [PATCH] cleanup(libsinsp): simplify k8s sandbox id filterchecks Signed-off-by: Melissa Kilby --- userspace/libsinsp/sinsp_filtercheck_k8s.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/userspace/libsinsp/sinsp_filtercheck_k8s.cpp b/userspace/libsinsp/sinsp_filtercheck_k8s.cpp index 0496b37209..6905c293c8 100644 --- a/userspace/libsinsp/sinsp_filtercheck_k8s.cpp +++ b/userspace/libsinsp/sinsp_filtercheck_k8s.cpp @@ -258,25 +258,21 @@ uint8_t* sinsp_filter_check_k8s::extract(sinsp_evt *evt, OUT uint32_t* len, bool } break; case TYPE_K8S_POD_SANDBOX_ID: + case TYPE_K8S_POD_FULL_SANDBOX_ID: // presence of io.kubernetes.sandbox.id is enforced based on the info.sandboxID in the container status response if(container_info->m_labels.count("io.kubernetes.sandbox.id") > 0) { m_tstr = container_info->m_labels.at("io.kubernetes.sandbox.id"); - if(m_tstr.size() > 12) + if(m_field_id == TYPE_K8S_POD_SANDBOX_ID) { - m_tstr.resize(12); + if(m_tstr.size() > 12) + { + m_tstr.resize(12); + } } RETURN_EXTRACT_STRING(m_tstr); } break; - case TYPE_K8S_POD_FULL_SANDBOX_ID: - // presence of io.kubernetes.sandbox.id is enforced based on the info.sandboxID in the container status response - if(container_info->m_labels.count("io.kubernetes.sandbox.id") > 0) - { - m_tstr = container_info->m_labels.at("io.kubernetes.sandbox.id"); - RETURN_EXTRACT_STRING(m_tstr); - } - break; case TYPE_K8S_POD_LABEL: case TYPE_K8S_POD_LABELS: if(container_info->m_labels.count("io.kubernetes.sandbox.id") > 0)