!52 lcr: sync with upstream

From: @lifeng2221dd1
Reviewed-by: @duguhaotian
Signed-off-by: @duguhaotian
This commit is contained in:
openeuler-ci-bot 2021-02-02 11:19:09 +08:00 committed by Gitee
commit 6ac27845f8
3 changed files with 152 additions and 1 deletions

View File

@ -0,0 +1,90 @@
From 1b25d3822a3794e7edfaeec14628b1f5c0b1089b Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
Date: Sat, 30 Jan 2021 14:30:55 +0800
Subject: [PATCH 1/2] support quiet of log config
Signed-off-by: haozi007 <liuhao27@huawei.com>
---
tests/log_ut.cpp | 8 ++++----
third_party/log.c | 17 ++++++++---------
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/tests/log_ut.cpp b/tests/log_ut.cpp
index 3694160..8cf6599 100644
--- a/tests/log_ut.cpp
+++ b/tests/log_ut.cpp
@@ -40,18 +40,18 @@ TEST(log_testcases, test_isula_libutils_default_log_config)
isula_libutils_default_log_config(name, &tconf);
ASSERT_EQ(tconf.file, nullptr);
- ASSERT_EQ(tconf.driver, nullptr);
+ EXPECT_STREQ(tconf.driver, ISULA_LOG_DRIVER_STDOUT);
EXPECT_STREQ(name, tconf.name);
- EXPECT_STREQ("FATAL", tconf.priority);
+ EXPECT_STREQ("DEBUG", tconf.priority);
// not quiet configs check
tconf.quiet = false;
isula_libutils_default_log_config(name, &tconf);
ASSERT_EQ(tconf.file, nullptr);
- ASSERT_NE(tconf.driver, nullptr);
+ EXPECT_STREQ(tconf.driver, ISULA_LOG_DRIVER_STDOUT);
EXPECT_STREQ(name, tconf.name);
- EXPECT_STREQ(ISULA_LOG_DRIVER_STDOUT, tconf.driver);
+ EXPECT_STREQ("DEBUG", tconf.priority);
}
static void check_log(int fd, bool exist, bool subcheck, const char *target)
diff --git a/third_party/log.c b/third_party/log.c
index 83de005..2fcb014 100644
--- a/third_party/log.c
+++ b/third_party/log.c
@@ -79,11 +79,9 @@ void isula_libutils_default_log_config(const char *name, struct isula_libutils_l
{
log->name = name;
log->file = NULL;
- // use to disable log
- log->priority = "FATAL";
- if (!log->quiet) {
- log->driver = ISULA_LOG_DRIVER_STDOUT;
- }
+ log->priority = "DEBUG";
+ log->quiet = true;
+ log->driver = ISULA_LOG_DRIVER_STDOUT;
}
void isula_libutils_set_log_prefix(const char *prefix)
@@ -103,9 +101,6 @@ void isula_libutils_free_log_prefix(void)
/*---------------------------------------------------------------------------*/
static int log_append_stderr(const struct lxc_log_appender *appender, struct lxc_log_event *event)
{
- if (event->priority < LXC_LOG_LEVEL_ERROR)
- return 0;
-
if (event->locinfo->file == NULL) {
return 0;
}
@@ -410,6 +405,11 @@ int isula_libutils_log_enable(const struct isula_libutils_log_config *log)
return 0;
}
+ if (log->quiet) {
+ g_lxc_log_category_lxc.priority = LXC_LOG_LEVEL_FATAL;
+ return 0;
+ }
+
if (!choice_log_driver(log)) {
COMMAND_ERROR("Invalid log config of driver");
return -1;
@@ -422,7 +422,6 @@ int isula_libutils_log_enable(const struct isula_libutils_log_config *log)
isula_libutils_set_log_prefix(log->prefix != NULL ? log->prefix : log->name);
-
return 0;
}
--
2.25.1

View File

@ -0,0 +1,53 @@
From 7129e7bc07005452f1b965e206e56134c1119a04 Mon Sep 17 00:00:00 2001
From: Li Feng <lifeng2221dd1@zoho.com.cn>
Date: Thu, 28 Jan 2021 19:17:22 +0800
Subject: [PATCH 2/2] lcr: add inactive file total metric
Signed-off-by: Li Feng <lifeng2221dd1@zoho.com.cn>
---
src/json/schema/container/info.json | 3 +++
src/lcrcontainer.h | 1 +
src/lcrcontainer_execute.c | 1 +
3 files changed, 5 insertions(+)
diff --git a/src/json/schema/container/info.json b/src/json/schema/container/info.json
index e554556..8ce10af 100644
--- a/src/json/schema/container/info.json
+++ b/src/json/schema/container/info.json
@@ -55,6 +55,9 @@
},
"cache_total": {
"type": "uint64"
+ },
+ "inactive_file_total": {
+ "type": "uint64"
}
}
}
diff --git a/src/lcrcontainer.h b/src/lcrcontainer.h
index 68014ba..dcd1b12 100644
--- a/src/lcrcontainer.h
+++ b/src/lcrcontainer.h
@@ -98,6 +98,7 @@ struct lcr_container_state {
/* Cache usage */
uint64_t cache;
uint64_t cache_total;
+ uint64_t inactive_file_total;
};
typedef enum {
diff --git a/src/lcrcontainer_execute.c b/src/lcrcontainer_execute.c
index 2091b49..ab04c7e 100644
--- a/src/lcrcontainer_execute.c
+++ b/src/lcrcontainer_execute.c
@@ -500,6 +500,7 @@ void do_lcr_state(struct lxc_container *c, struct lcr_container_state *lcs)
lcs->cache = lxc_metrics.cache;
lcs->cache_total = lxc_metrics.cache_total;
+ lcs->inactive_file_total = lxc_metrics.inactive_file_total;
}
#define ExitSignalOffset 128
--
2.25.1

View File

@ -1,5 +1,5 @@
%global _version 2.0.5 %global _version 2.0.5
%global _release 20201230.150203.git5e91f13f %global _release 20210202.093043.git36603cff
%global _inner_name isula_libutils %global _inner_name isula_libutils
Name: lcr Name: lcr
@ -12,6 +12,9 @@ Group: Applications/System
License: LGPLv2.1+ License: LGPLv2.1+
BuildRoot: %{_tmppath}/lcr-%{version} BuildRoot: %{_tmppath}/lcr-%{version}
Patch1: 0001-support-quiet-of-log-config.patch
Patch2: 0002-lcr-add-inactive-file-total-metric.patch
BuildRequires: cmake BuildRequires: cmake
BuildRequires: lxc BuildRequires: lxc
BuildRequires: lxc-devel BuildRequires: lxc-devel
@ -99,6 +102,11 @@ rm -rf %{buildroot}
%changelog %changelog
* Tue Feb 2 2021 lifeng <lifeng68@huawei.com> - 2.0.5-20210202.093043.git36603cff
- Type:sync with upstream
- ID:NA
- SUG:NA
* Wed Dec 30 2020 lifeng <lifeng68@huawei.com> - 2.0.5-20201230.150203.git5e91f13f * Wed Dec 30 2020 lifeng <lifeng68@huawei.com> - 2.0.5-20201230.150203.git5e91f13f
- Type:update to v2.0.5 - Type:update to v2.0.5
- ID:NA - ID:NA