Skip to content

Commit

Permalink
Fix cri::resolve to work w UNKNOWN container infos
Browse files Browse the repository at this point in the history
cri::resolve might be called after docker::resolve, so there could be a
container_info object with type == UNKNOWN.

Update it to handle this i.e. do the lookup anyway.
  • Loading branch information
mstemm committed Mar 7, 2019
1 parent d5e79c0 commit aa5c232
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions userspace/libsinsp/container_engine/cri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,24 @@ void cri::set_extra_queries(bool extra_queries) {
bool cri::resolve(sinsp_container_manager* manager, sinsp_threadinfo* tinfo, bool query_os_for_missing_info)
{
sinsp_container_info container_info;
sinsp_container_info *existing_container_info;

if(matches_runc_cgroups(tinfo, CRI_CGROUP_LAYOUT, container_info.m_id))
{
container_info.m_type = s_cri_runtime_type;
// It might also be a docker container, so set the type
// to UNKNOWN for now.
container_info.m_type = CT_UNKNOWN;
}
else
{
return false;
}
tinfo->m_container_id = container_info.m_id;
if (!manager->container_exists(container_info.m_id))

existing_container_info = manager->get_container(container_info.m_id);

if (!existing_container_info ||
existing_container_info->m_type == CT_UNKNOWN)
{
if (query_os_for_missing_info)
{
Expand All @@ -213,6 +220,11 @@ bool cri::resolve(sinsp_container_manager* manager, sinsp_threadinfo* tinfo, boo
container_info.m_id.c_str());
return false;
}

// If here, parse_cri succeeded so we can
// assign an actual type.
container_info.m_type = s_cri_runtime_type;

}
if (mesos::set_mesos_task_id(&container_info, tinfo))
{
Expand Down

0 comments on commit aa5c232

Please sign in to comment.