diff --git a/userspace/libsinsp/container_engine/cri.cpp b/userspace/libsinsp/container_engine/cri.cpp index 1a01d1b008..9a93603611 100644 --- a/userspace/libsinsp/container_engine/cri.cpp +++ b/userspace/libsinsp/container_engine/cri.cpp @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2023 The Falco Authors. +Copyright (C) 2024 The Falco Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -282,16 +282,6 @@ sinsp_container_type cri::get_cri_runtime_type() const { } } -std::optional cri::get_writable_layer_size(const string &container_id) { - if(m_cri_v1) { - return m_cri_v1->get_writable_layer_size(container_id); - } else if(m_cri_v1alpha2) { - return m_cri_v1alpha2->get_writable_layer_size(container_id); - } else { - return std::nullopt; - } -} - bool cri_async_source::parse(const cri_async_source::key_type &key, sinsp_container_info &container) { if(m_cri_v1) { diff --git a/userspace/libsinsp/container_engine/cri.h b/userspace/libsinsp/container_engine/cri.h index 987f3fdd6f..946e45b291 100644 --- a/userspace/libsinsp/container_engine/cri.h +++ b/userspace/libsinsp/container_engine/cri.h @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2023 The Falco Authors. +Copyright (C) 2024 The Falco Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -90,8 +90,6 @@ class cri : public container_engine_base { private: [[nodiscard]] sinsp_container_type get_cri_runtime_type() const; - std::optional get_writable_layer_size(const std::string& container_id); - std::unique_ptr m_async_source; std::unique_ptr<::libsinsp::cri::cri_interface_v1alpha2> m_cri_v1alpha2; std::unique_ptr<::libsinsp::cri::cri_interface_v1> m_cri_v1; diff --git a/userspace/libsinsp/cri.h b/userspace/libsinsp/cri.h index 6ee41949f6..b78650b59c 100644 --- a/userspace/libsinsp/cri.h +++ b/userspace/libsinsp/cri.h @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2023 The Falco Authors. +Copyright (C) 2024 The Falco Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -216,14 +216,6 @@ class cri_interface { */ std::string get_container_image_id(const std::string &image_ref); - /** - * @brief get the size of the container's writable layer via ContainerStat API calls - * @param container_id container ID - * @note currently unused - * @return the size of the writable layer in bytes. Returns an empty option on error - */ - std::optional get_writable_layer_size(const std::string &container_id); - /////////////////////////////////////////////////////////// // CRI response (ContainerStatusResponse) parsers helpers /////////////////////////////////////////////////////////// diff --git a/userspace/libsinsp/cri.hpp b/userspace/libsinsp/cri.hpp index 7f742204b2..e5b7fbc3a4 100644 --- a/userspace/libsinsp/cri.hpp +++ b/userspace/libsinsp/cri.hpp @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2023 The Falco Authors. +Copyright (C) 2024 The Falco Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -163,53 +163,6 @@ inline std::string cri_interface::get_container_image_id(const std::string return ""; } -template -inline std::optional cri_interface::get_writable_layer_size( - const std::string &container_id) { - // Synchronously get the stats response and update the container table. - // Note that this needs to use the full id. - typename api::ContainerStatsResponse resp; - grpc::Status status = get_container_stats_resp(container_id, resp); - - libsinsp_logger()->format( - sinsp_logger::SEV_DEBUG, - "cri (%s): Status from ContainerStats: (%s)", - container_id.c_str(), - status.error_message().empty() ? "SUCCESS" : status.error_message().c_str()); - - if(!status.ok()) { - return std::nullopt; - } - - if(!resp.has_stats()) { - libsinsp_logger()->format(sinsp_logger::SEV_DEBUG, - "cri (%s): Failed to update size: stats() not found", - container_id.c_str()); - ASSERT(false); - return std::nullopt; - } - - const auto &resp_stats = resp.stats(); - - if(!resp_stats.has_writable_layer()) { - libsinsp_logger()->format(sinsp_logger::SEV_DEBUG, - "cri (%s): Failed to update size: writable_layer() not found", - container_id.c_str()); - ASSERT(false); - return std::nullopt; - } - - if(!resp_stats.writable_layer().has_used_bytes()) { - libsinsp_logger()->format(sinsp_logger::SEV_DEBUG, - "cri (%s): Failed to update size: used_bytes() not found", - container_id.c_str()); - ASSERT(false); - return std::nullopt; - } - - return resp_stats.writable_layer().used_bytes().value(); -} - ///////////////////////////// // Generic parsers helpers /////////////////////////////