Skip to content

Commit

Permalink
Make extra CRI queries configurable (enabled by default)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnosek committed Feb 20, 2019
1 parent 3c330d9 commit e4e4ae4
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 2 deletions.
7 changes: 7 additions & 0 deletions userspace/libsinsp/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,13 @@ void sinsp_container_manager::set_query_docker_image_info(bool query_image_info)
libsinsp::container_engine::docker::set_query_image_info(query_image_info);
}

void sinsp_container_manager::set_cri_extra_queries(bool extra_queries)
{
#if defined(HAS_CAPTURE)
libsinsp::container_engine::cri::set_extra_queries(extra_queries);
#endif
}

void sinsp_container_manager::set_cri_socket_path(const std::string &path)
{
#if defined(HAS_CAPTURE)
Expand Down
1 change: 1 addition & 0 deletions userspace/libsinsp/container.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class sinsp_container_manager
void cleanup();

void set_query_docker_image_info(bool query_image_info);
void set_cri_extra_queries(bool extra_queries);
void set_cri_socket_path(const std::string& path);
void set_cri_timeout(int64_t timeout_ms);
sinsp* get_inspector() { return m_inspector; }
Expand Down
12 changes: 10 additions & 2 deletions userspace/libsinsp/container_engine/cri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,11 @@ bool parse_cri(sinsp_container_manager *manager, sinsp_container_info *container
return true;
}

container->m_container_ip = get_container_ip(container->m_id);
container->m_imageid = get_container_image_id(resp_container.image_ref());
if(s_cri_extra_queries)
{
container->m_container_ip = get_container_ip(container->m_id);
container->m_imageid = get_container_image_id(resp_container.image_ref());
}

return true;
}
Expand Down Expand Up @@ -171,6 +174,7 @@ void cri::cleanup()
{
s_cri.reset(nullptr);
s_cri_image.reset(nullptr);
s_cri_extra_queries = true;
}

void cri::set_cri_socket_path(const std::string& path)
Expand All @@ -183,6 +187,10 @@ void cri::set_cri_timeout(int64_t timeout_ms)
s_cri_timeout = timeout_ms;
}

void cri::set_extra_queries(bool extra_queries) {
s_cri_extra_queries = extra_queries;
}

bool cri::resolve(sinsp_container_manager* manager, sinsp_threadinfo* tinfo, bool query_os_for_missing_info)
{
sinsp_container_info container_info;
Expand Down
1 change: 1 addition & 0 deletions userspace/libsinsp/container_engine/cri.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class cri
static void cleanup();
static void set_cri_socket_path(const std::string& path);
static void set_cri_timeout(int64_t timeout_ms);
static void set_extra_queries(bool extra_queries);
};
}
}
1 change: 1 addition & 0 deletions userspace/libsinsp/cri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ std::unique_ptr <runtime::v1alpha2::RuntimeService::Stub> s_cri = nullptr;
std::unique_ptr <runtime::v1alpha2::ImageService::Stub> s_cri_image = nullptr;
int64_t s_cri_timeout = 1000;
sinsp_container_type s_cri_runtime_type = CT_CRI;
bool s_cri_extra_queries = true;

sinsp_container_type get_cri_runtime_type(const std::string &runtime_name)
{
Expand Down
1 change: 1 addition & 0 deletions userspace/libsinsp/cri.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ extern std::unique_ptr<runtime::v1alpha2::RuntimeService::Stub> s_cri;
extern std::unique_ptr<runtime::v1alpha2::ImageService::Stub> s_cri_image;
extern int64_t s_cri_timeout;
extern sinsp_container_type s_cri_runtime_type;
extern bool s_cri_extra_queries;

sinsp_container_type get_cri_runtime_type(const std::string &runtime_name);

Expand Down
5 changes: 5 additions & 0 deletions userspace/libsinsp/sinsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,11 @@ void sinsp::set_query_docker_image_info(bool query_image_info)
m_container_manager.set_query_docker_image_info(query_image_info);
}

void sinsp::set_cri_extra_queries(bool extra_queries)
{
m_container_manager.set_cri_extra_queries(extra_queries);
}

void sinsp::set_cri_socket_path(const std::string& path)
{
m_container_manager.set_cri_socket_path(path);
Expand Down
2 changes: 2 additions & 0 deletions userspace/libsinsp/sinsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,8 @@ class SINSP_PUBLIC sinsp

void set_query_docker_image_info(bool query_image_info);

void set_cri_extra_queries(bool extra_queries);

void set_fullcapture_port_range(uint16_t range_start, uint16_t range_end);

void set_cri_socket_path(const std::string& path);
Expand Down

0 comments on commit e4e4ae4

Please sign in to comment.