Skip to content

Commit

Permalink
Serialize/unserialize is_pod_sandbox
Browse files Browse the repository at this point in the history
Instead of inferring is_pod_sandbox from the container name only for
docker, save/load it to json directly from the container info. This
ensures it works for other container engines than docker.
  • Loading branch information
mstemm committed Mar 25, 2019
1 parent 0eb84d4 commit 6a5a176
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions userspace/libsinsp/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ string sinsp_container_manager::container_to_json(const sinsp_container_info& co
container["imagetag"] = container_info.m_imagetag;
container["imagedigest"] = container_info.m_imagedigest;
container["privileged"] = container_info.m_privileged;
container["is_pod_sandbox"] = container_info.m_is_pod_sandbox;

Json::Value mounts = Json::arrayValue;

Expand Down
11 changes: 7 additions & 4 deletions userspace/libsinsp/parsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4500,11 +4500,14 @@ void sinsp_parser::parse_container_json_evt(sinsp_evt *evt)
if(!name.isNull() && name.isConvertibleTo(Json::stringValue))
{
container_info.m_name = name.asString();
if(container_info.m_type == CT_DOCKER && container_info.m_name.find("k8s_POD") == 0)
{
container_info.m_is_pod_sandbox = true;
}
}

const Json::Value& is_pod_sandbox = container["isPodSandbox"];
if(!is_pod_sandbox.isNull() && is_pod_sandbox.isConvertibleTo(Json::booleanValue))
{
container_info.m_is_pod_sandbox = is_pod_sandbox.asBool();
}

const Json::Value& image = container["image"];
if(!image.isNull() && image.isConvertibleTo(Json::stringValue))
{
Expand Down

0 comments on commit 6a5a176

Please sign in to comment.