From 745e4a3ca9ac2f3908bde0a529091153d93e753f Mon Sep 17 00:00:00 2001 From: jikui Date: Thu, 25 Nov 2021 19:20:55 +0800 Subject: [PATCH] kata-runtime: runcate the log.json file before kata-runtime subcommand executed Signed-off-by: jikui --- kata-containers.spec | 8 ++++- ...ncate-the-log.json-file-before-kata-.patch | 33 +++++++++++++++++++ series.conf | 1 + 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 patches/0015-kata-containers-truncate-the-log.json-file-before-kata-.patch diff --git a/kata-containers.spec b/kata-containers.spec index d031e89..9625078 100644 --- a/kata-containers.spec +++ b/kata-containers.spec @@ -2,7 +2,7 @@ %global debug_package %{nil} %define VERSION 2.1.0 -%define RELEASE 11 +%define RELEASE 12 Name: kata-containers Version: %{VERSION} @@ -108,6 +108,12 @@ strip %{buildroot}/usr/bin/containerd-shim-kata-v2 %doc %changelog +* Thu Nov 25 2021 jikui - 2.1.0-12 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:truncate the log.json file before kata-runtime subcommand executed + * Thu Nov 25 2021 jikui - 2.1.0-11 - Type:bugfix - ID:NA diff --git a/patches/0015-kata-containers-truncate-the-log.json-file-before-kata-.patch b/patches/0015-kata-containers-truncate-the-log.json-file-before-kata-.patch new file mode 100644 index 0000000..3edf5ed --- /dev/null +++ b/patches/0015-kata-containers-truncate-the-log.json-file-before-kata-.patch @@ -0,0 +1,33 @@ +From fe490b4d63871f91c17ad72afef38a3227c8b4d3 Mon Sep 17 00:00:00 2001 +From: jikui +Date: Fri, 5 Nov 2021 12:06:11 +0800 +Subject: [PATCH 6/8] kata-runtime: truncate the log.json file before + kata-runtime subcommand executed + +Signed-off-by: jikui +--- + src/runtime/cli/main.go | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/src/runtime/cli/main.go b/src/runtime/cli/main.go +index 27757c0..7c77764 100644 +--- a/src/runtime/cli/main.go ++++ b/src/runtime/cli/main.go +@@ -252,6 +252,14 @@ func beforeSubcommands(c *cli.Context) error { + ignoreConfigLogs = true + } else { + if path := c.GlobalString("log"); path != "" { ++ // since we have redirect the kata-runtime log to /var/log/messages, and avoid the ++ // path of log.json file to be large in the tmpfs, so we truncate the log.json file ++ // every time before subcommand is executed. ++ if path != "/dev/null" && katautils.FileExists(path) { ++ if err := os.Truncate(path, 0); err != nil { ++ return err ++ } ++ } + f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_APPEND|os.O_SYNC, 0640) + if err != nil { + return err +-- +2.25.1 + diff --git a/series.conf b/series.conf index 19ebfe4..37b33d8 100644 --- a/series.conf +++ b/series.conf @@ -12,3 +12,4 @@ 0012-kata-containers-modify-kernel-and-image-path-in-conf.patch 0013-kata-containers-increase-delete-cgroup-retry-times.patch 0014-kata-containers-fix-umount-container-rootfs-dir-return-.patch +0015-kata-containers-truncate-the-log.json-file-before-kata-.patch -- Gitee