提交 5646e5f7 编写于 作者: G gaohuatao 提交者: lifeng68

devmapper: fix cri get fsusage bug to adapt devmapper

Signed-off-by: Ngaohuatao <gaohuatao@huawei.com>
上级 2ff368ca
...@@ -891,6 +891,29 @@ void CRIRuntimeServiceImpl::PackContainerStatsAttributes( ...@@ -891,6 +891,29 @@ void CRIRuntimeServiceImpl::PackContainerStatsAttributes(
} }
} }
static void SetFsUsage(const imagetool_fs_info *fs_usage, std::unique_ptr<runtime::v1alpha2::ContainerStats> &container)
{
if (fs_usage == nullptr || fs_usage->image_filesystems[0] == nullptr) {
container->mutable_writable_layer()->mutable_used_bytes()->set_value(0);
container->mutable_writable_layer()->mutable_inodes_used()->set_value(0);
return;
}
if (fs_usage->image_filesystems[0]->used_bytes == nullptr) {
container->mutable_writable_layer()->mutable_used_bytes()->set_value(0);
} else {
container->mutable_writable_layer()->mutable_used_bytes()->set_value(
fs_usage->image_filesystems[0]->used_bytes->value);
}
if (fs_usage->image_filesystems[0]->inodes_used == nullptr) {
container->mutable_writable_layer()->mutable_inodes_used()->set_value(0);
} else {
container->mutable_writable_layer()->mutable_inodes_used()->set_value(
fs_usage->image_filesystems[0]->inodes_used->value);
}
}
void CRIRuntimeServiceImpl::PackContainerStatsFilesystemUsage( void CRIRuntimeServiceImpl::PackContainerStatsFilesystemUsage(
const char *id, const char *image_type, const char *id, const char *image_type,
std::unique_ptr<runtime::v1alpha2::ContainerStats> &container, std::unique_ptr<runtime::v1alpha2::ContainerStats> &container,
...@@ -905,21 +928,7 @@ void CRIRuntimeServiceImpl::PackContainerStatsFilesystemUsage( ...@@ -905,21 +928,7 @@ void CRIRuntimeServiceImpl::PackContainerStatsFilesystemUsage(
ERROR("Failed to get container filesystem usage"); ERROR("Failed to get container filesystem usage");
} }
if (fs_usage == nullptr) { SetFsUsage(fs_usage, container);
container->mutable_writable_layer()->mutable_used_bytes()->set_value(0);
container->mutable_writable_layer()->mutable_inodes_used()->set_value(0);
} else {
if (fs_usage->image_filesystems[0]->used_bytes->value) {
container->mutable_writable_layer()->mutable_used_bytes()->set_value(
fs_usage->image_filesystems[0]->used_bytes->value);
}
if (fs_usage->image_filesystems[0]->inodes_used->value) {
container->mutable_writable_layer()->mutable_inodes_used()->set_value(
fs_usage->image_filesystems[0]->inodes_used->value);
}
}
free_imagetool_fs_info(fs_usage); free_imagetool_fs_info(fs_usage);
} }
......
...@@ -789,6 +789,7 @@ static void construct_device_id_map(struct device_set *devset) ...@@ -789,6 +789,7 @@ static void construct_device_id_map(struct device_set *devset)
mark_device_id_used(devset, device_info->info->device_id); mark_device_id_used(devset, device_info->info->device_id);
devmapper_device_info_ref_dec(device_info); devmapper_device_info_ref_dec(device_info);
} }
util_free_array(dev_arr);
} }
static void count_deleted_devices(struct device_set *devset) static void count_deleted_devices(struct device_set *devset)
...@@ -812,6 +813,7 @@ static void count_deleted_devices(struct device_set *devset) ...@@ -812,6 +813,7 @@ static void count_deleted_devices(struct device_set *devset)
} }
devmapper_device_info_ref_dec(device_info); devmapper_device_info_ref_dec(device_info);
} }
util_free_array(dev_arr);
} }
static int remove_transaction_metadata(struct device_set *devset) static int remove_transaction_metadata(struct device_set *devset)
...@@ -2383,6 +2385,8 @@ static int do_check_all_devices(struct device_set *devset) ...@@ -2383,6 +2385,8 @@ static int do_check_all_devices(struct device_set *devset)
if (!util_has_prefix(devices_list[i], devset->device_prefix)) { if (!util_has_prefix(devices_list[i], devset->device_prefix)) {
continue; continue;
} }
UTIL_FREE_AND_SET_NULL(target_type);
UTIL_FREE_AND_SET_NULL(params);
if (dev_get_status(&start, &length, &target_type, &params, devices_list[i]) != 0) { if (dev_get_status(&start, &length, &target_type, &params, devices_list[i]) != 0) {
WARN("devmapper: get device status %s failed", devices_list[i]); WARN("devmapper: get device status %s failed", devices_list[i]);
continue; continue;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册