Skip to content

Commit

Permalink
cleanup(libsinsp): simplify k8s sandbox id filterchecks
Browse files Browse the repository at this point in the history
Signed-off-by: Melissa Kilby <[email protected]>
  • Loading branch information
incertum authored and poiana committed Dec 16, 2023
1 parent 93cae84 commit 2fe0898
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions userspace/libsinsp/sinsp_filtercheck_k8s.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2fe0898

Please sign in to comment.