diff --git a/kata-containers.spec b/kata-containers.spec index d031e891b5c3d295d17b9dc5ff7b7cc5b03dd297..962507840f13d6213a1a818c8c595b4f3c169691 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 0000000000000000000000000000000000000000..3edf5eddb6cf87417edd4fd74c8b3763193b95b5 --- /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 19ebfe430a36418bc4665c761615c53cd8005547..37b33d84151327ec17a144d3656e4102c025cbbe 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