Skip to content

Commit

Permalink
chore(libsinsp): remove unused update_with_size method from `contai…
Browse files Browse the repository at this point in the history
…ner_engine`

Signed-off-by: Leonardo Grasso <[email protected]>
  • Loading branch information
leogr committed Oct 21, 2024
1 parent ea9449b commit f2a81a9
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 66 deletions.
4 changes: 0 additions & 4 deletions userspace/libsinsp/container_engine/container_engine_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ namespace container_engine {

container_engine_base::container_engine_base(container_cache_interface &cache): m_cache(cache) {}

void container_engine_base::update_with_size(const std::string &container_id) {
SINSP_DEBUG("Updating container size not supported for this container type.");
}

void container_engine_base::cleanup() {}

} // namespace container_engine
Expand Down
7 changes: 0 additions & 7 deletions userspace/libsinsp/container_engine/container_engine_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,6 @@ class container_engine_base {
*/
virtual bool resolve(sinsp_threadinfo* tinfo, bool query_os_for_missing_info) = 0;

/**
* Update an existing container with the size of the container layer.
* The size is not requested as the part of the initial request (in resolve)
* because determining the size can take seconds.
*/
virtual void update_with_size(const std::string& container_id);

virtual void cleanup();

protected:
Expand Down
28 changes: 0 additions & 28 deletions userspace/libsinsp/container_engine/cri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,34 +272,6 @@ bool cri::resolve(sinsp_threadinfo *tinfo, bool query_os_for_missing_info) {
return true;
}

void cri::update_with_size(const std::string &container_id) {
sinsp_container_info::ptr_t existing = container_cache().get_container(container_id);
if(!existing) {
libsinsp_logger()->format(sinsp_logger::SEV_ERROR,
"cri (%s): Failed to locate existing container data",
container_id.c_str());
ASSERT(false);
return;
}

std::optional<int64_t> writable_layer_size = get_writable_layer_size(existing->m_full_id);

if(!writable_layer_size.has_value()) {
return;
}

// Make a mutable copy of the existing container_info
shared_ptr<sinsp_container_info> updated(std::make_shared<sinsp_container_info>(*existing));
updated->m_size_rw_bytes = *writable_layer_size;

if(existing->m_size_rw_bytes == updated->m_size_rw_bytes) {
// no data has changed
return;
}

container_cache().replace_container(updated);
}

sinsp_container_type cri::get_cri_runtime_type() const {
if(m_cri_v1) {
return m_cri_v1->get_cri_runtime_type();
Expand Down
1 change: 0 additions & 1 deletion userspace/libsinsp/container_engine/cri.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ class cri : public container_engine_base {
public:
cri(container_cache_interface& cache);
bool resolve(sinsp_threadinfo* tinfo, bool query_os_for_missing_info) override;
void update_with_size(const std::string& container_id) override;
void cleanup() override;
static void set_cri_socket_path(const std::string& path);
static void add_cri_socket_path(const std::string& path);
Expand Down
24 changes: 0 additions & 24 deletions userspace/libsinsp/container_engine/docker/docker_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,3 @@ bool docker_linux::resolve(sinsp_threadinfo* tinfo, bool query_os_for_missing_in
docker_lookup_request(container_id, s_docker_sock, CT_DOCKER, 0, false),
query_os_for_missing_info);
}

void docker_linux::update_with_size(const std::string& container_id) {
auto cb = [this](const docker_lookup_request& instruction, const sinsp_container_info& res) {
libsinsp_logger()->format(sinsp_logger::SEV_DEBUG,
"docker_async (%s): with size callback result=%d",
instruction.container_id.c_str(),
res.get_lookup_status());

sinsp_container_info::ptr_t updated = std::make_shared<sinsp_container_info>(res);
container_cache().replace_container(updated);
};

libsinsp_logger()->format(sinsp_logger::SEV_DEBUG,
"docker_async size request (%s)",
container_id.c_str());

sinsp_container_info result;
docker_lookup_request instruction(container_id,
s_docker_sock,
CT_DOCKER,
0,
true /*request rw size*/);
(void)m_docker_info_source->lookup(instruction, result, cb);
}
2 changes: 0 additions & 2 deletions userspace/libsinsp/container_engine/docker/docker_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class docker_linux : public docker_base {
// implement container_engine_base
bool resolve(sinsp_threadinfo* tinfo, bool query_os_for_missing_info) override;

void update_with_size(const std::string& container_id) override;

private:
static std::string s_docker_sock;
};
Expand Down

0 comments on commit f2a81a9

Please sign in to comment.