1 Star 0 Fork 43

zhongtao/src-iSulad

forked from src-openEuler/iSulad 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0022-add-swap-usage-in-cri.patch 3.65 KB
一键复制 编辑 原始数据 按行查看 历史
jake 提交于 2024-04-02 11:50 . upgrade from upstream
From ed569ccbf7e5029e83c40521255e0e406f285bae Mon Sep 17 00:00:00 2001
From: jikai <[email protected]>
Date: Fri, 12 Jan 2024 11:31:59 +0800
Subject: [PATCH 22/43] add swap usage in cri
Signed-off-by: jikai <[email protected]>
---
.../entry/cri/v1/v1_cri_container_manager_service.cc | 11 +++++++++++
src/daemon/executor/container_cb/execution_extend.c | 2 ++
src/daemon/modules/api/runtime_api.h | 3 +++
src/daemon/modules/runtime/isula/isula_rt_ops.c | 4 ++++
4 files changed, 20 insertions(+)
diff --git a/src/daemon/entry/cri/v1/v1_cri_container_manager_service.cc b/src/daemon/entry/cri/v1/v1_cri_container_manager_service.cc
index 2dda1e16..47a33c2c 100644
--- a/src/daemon/entry/cri/v1/v1_cri_container_manager_service.cc
+++ b/src/daemon/entry/cri/v1/v1_cri_container_manager_service.cc
@@ -890,6 +890,17 @@ void ContainerManagerService::ContainerStatsToGRPC(
if (response->container_stats[i]->major_page_faults != 0u) {
container->mutable_memory()->mutable_major_page_faults()->set_value(response->container_stats[i]->major_page_faults);
}
+
+ // Swap
+ container->mutable_swap()->set_timestamp(timestamp);
+ if (response->container_stats[i]->swap_used != 0u) {
+ container->mutable_swap()->mutable_swap_usage_bytes()->set_value(response->container_stats[i]->swap_used);
+ }
+ if (response->container_stats[i]->swap_limit >= response->container_stats[i]->swap_used) {
+ container->mutable_swap()->mutable_swap_available_bytes()->set_value(response->container_stats[i]->swap_limit
+ - response->container_stats[i]->swap_used);
+ }
+
containerstats.push_back(std::move(container));
}
}
diff --git a/src/daemon/executor/container_cb/execution_extend.c b/src/daemon/executor/container_cb/execution_extend.c
index 25ec5d3b..52401633 100644
--- a/src/daemon/executor/container_cb/execution_extend.c
+++ b/src/daemon/executor/container_cb/execution_extend.c
@@ -259,6 +259,8 @@ static container_info *get_container_stats(const container_t *cont,
info->major_page_faults = einfo->major_page_faults;
info->kmem_used = einfo->kmem_used;
info->kmem_limit = einfo->kmem_limit;
+ info->swap_used = einfo->swap_used;
+ info->swap_limit = einfo->swap_limit;
info->timestamp = util_get_now_time_nanos();
// workingset is zero if memory used < total inactive file
diff --git a/src/daemon/modules/api/runtime_api.h b/src/daemon/modules/api/runtime_api.h
index d2679c2d..bd170c30 100644
--- a/src/daemon/modules/api/runtime_api.h
+++ b/src/daemon/modules/api/runtime_api.h
@@ -66,6 +66,9 @@ struct runtime_container_resources_stats_info {
uint64_t cache;
uint64_t cache_total;
uint64_t inactive_file_total;
+ /* Swap usage*/
+ uint64_t swap_used;
+ uint64_t swap_limit;
};
typedef struct _rt_create_params_t {
diff --git a/src/daemon/modules/runtime/isula/isula_rt_ops.c b/src/daemon/modules/runtime/isula/isula_rt_ops.c
index 2c92cc59..745154bb 100644
--- a/src/daemon/modules/runtime/isula/isula_rt_ops.c
+++ b/src/daemon/modules/runtime/isula/isula_rt_ops.c
@@ -647,6 +647,10 @@ static void transform_stats_info_from_runtime(shim_client_runtime_stats *stats,
info->page_faults = memory->raw->pgfault;
info->major_page_faults = memory->raw->pgmajfault;
}
+ if (memory != NULL && memory->swap != NULL) {
+ info->swap_used = memory->swap->usage;
+ info->swap_limit = memory->swap->limit;
+ }
shim_client_runtime_stats_data_blkio *blkio = stats->data->blkio;
if (blkio == NULL) {
return;
--
2.34.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/taotao-sauce/src-iSulad.git
[email protected]:taotao-sauce/src-iSulad.git
taotao-sauce
src-iSulad
src-iSulad
master

搜索帮助