代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/iSulad 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。