Skip to content

Commit

Permalink
Further plumb CRI/containerd in sysdig (#1376)
Browse files Browse the repository at this point in the history
Signed-off-by: Spencer Krum <nibz@spencerkrum.com>

sysdig-CLA-1.0-contributing-entity: International Business Machines
sysdig-CLA-1.0-signed-off-by: Spencer Krum <skrum@us.ibm.com>
  • Loading branch information
nibalizer authored and mstemm committed Apr 26, 2019
1 parent be90e43 commit 2557098
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions userspace/libsinsp/k8s_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ limitations under the License.

const std::string k8s_state_t::m_docker_prefix = "docker://";
const std::string k8s_state_t::m_rkt_prefix = "rkt://";
const std::string k8s_state_t::m_containerd_prefix = "containerd://";
const unsigned k8s_state_t::m_id_length = 12u;

k8s_state_t::k8s_state_t(bool is_captured, int capture_version):
Expand Down Expand Up @@ -70,8 +71,15 @@ void k8s_state_t::cache_pod(container_pod_map& map, const std::string& id, const
map[id.substr(m_rkt_prefix.size())] = pod;
return;
}
throw sinsp_exception("Invalid container ID (expected '" + m_docker_prefix +
"{ID}' or '" + m_rkt_prefix + "{ID}'): " + id);
pos = id.find(m_containerd_prefix);
if( pos == 0)
{
map[id.substr(m_containerd_prefix.size(), m_id_length)] = pod;
return;
}
throw sinsp_exception("Invalid container ID (expected one of: '" + m_docker_prefix +
"{ID}', '" + m_rkt_prefix + "{ID}', '" + m_containerd_prefix +
"{ID}'): " + id);
}

bool k8s_state_t::has_pod(k8s_pod_t& pod)
Expand Down
1 change: 1 addition & 0 deletions userspace/libsinsp/k8s_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ class k8s_state_t

static const std::string m_docker_prefix; // "docker://"
static const std::string m_rkt_prefix; // "rkt://"
static const std::string m_containerd_prefix; // "containerd://"
static const unsigned m_id_length; // portion of the ID to be cached (=12)

#ifndef HAS_ANALYZER
Expand Down

0 comments on commit 2557098

Please sign in to comment.