runc: runc log forward to syslog
This commit is contained in:
parent
99b2a44578
commit
8318951e31
@ -1 +1 @@
|
||||
43d228d300f9de4c4071f6e8adb7205271383185
|
||||
caecfec06584770e48dcfba57461f7b89e08babe
|
||||
|
||||
88
patch/0029-runc-runc-log-forward-to-syslog.patch
Normal file
88
patch/0029-runc-runc-log-forward-to-syslog.patch
Normal file
@ -0,0 +1,88 @@
|
||||
From 0ee4b516f4e39ccef4b893a678b01095acbe6ad0 Mon Sep 17 00:00:00 2001
|
||||
From: zhongjiawei <zhongjiawei1@huawei.com>
|
||||
Date: Mon, 7 Nov 2022 18:56:11 +0800
|
||||
Subject: [PATCH] runc:runc log forward to syslog
|
||||
|
||||
---
|
||||
runc-1.1.3/main.go | 27 ++++++++++++++++++-
|
||||
.../sirupsen/logrus/hooks/syslog/syslog.go | 2 +-
|
||||
2 files changed, 27 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/runc-1.1.3/main.go b/runc-1.1.3/main.go
|
||||
index e52a2ea..381681e 100644
|
||||
--- a/runc-1.1.3/main.go
|
||||
+++ b/runc-1.1.3/main.go
|
||||
@@ -1,19 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
+ "encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
+ "log/syslog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
+ "time"
|
||||
|
||||
"github.com/opencontainers/runc/libcontainer/seccomp"
|
||||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
+ logrus_syslog "github.com/sirupsen/logrus/hooks/syslog"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -215,6 +219,12 @@ func configLogrus(context *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
logrus.SetOutput(f)
|
||||
+ hook, serr := logrus_syslog.NewSyslogHook("", "", syslog.LOG_INFO|syslog.LOG_USER, "docker-runc")
|
||||
+ if serr != nil {
|
||||
+ logToFile(f, "error", fmt.Sprintf("new syslog hook get %s", serr))
|
||||
+ } else {
|
||||
+ logrus.AddHook(hook)
|
||||
+ }
|
||||
}
|
||||
if logLevel := context.GlobalString("log-level"); logLevel != "" {
|
||||
lvl, err := logrus.ParseLevel(logLevel)
|
||||
@@ -230,4 +240,19 @@ func configLogrus(context *cli.Context) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
-
|
||||
+func logToFile(f io.Writer, level string, msg string) {
|
||||
+ var (
|
||||
+ log struct {
|
||||
+ Level string
|
||||
+ Msg string
|
||||
+ Time time.Time
|
||||
+ }
|
||||
+ )
|
||||
+ log.Level = level
|
||||
+ log.Msg = msg
|
||||
+ log.Time = time.Now()
|
||||
+ s, err := json.Marshal(log)
|
||||
+ if err != nil {
|
||||
+ fmt.Fprint(f, string(s))
|
||||
+ }
|
||||
+}
|
||||
diff --git a/runc-1.1.3/vendor/github.com/sirupsen/logrus/hooks/syslog/syslog.go b/runc-1.1.3/vendor/github.com/sirupsen/logrus/hooks/syslog/syslog.go
|
||||
index b6fa374..430f646 100644
|
||||
--- a/runc-1.1.3/vendor/github.com/sirupsen/logrus/hooks/syslog/syslog.go
|
||||
+++ b/runc-1.1.3/vendor/github.com/sirupsen/logrus/hooks/syslog/syslog.go
|
||||
@@ -2,7 +2,7 @@ package logrus_syslog
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
- "github.com/Sirupsen/logrus"
|
||||
+ "github.com/sirupsen/logrus"
|
||||
"log/syslog"
|
||||
"os"
|
||||
)
|
||||
--
|
||||
2.30.0
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
Name: docker-runc
|
||||
Version: 1.1.3
|
||||
Release: 5
|
||||
Release: 6
|
||||
Summary: runc is a CLI tool for spawning and running containers according to the OCI specification.
|
||||
|
||||
License: ASL 2.0
|
||||
@ -54,6 +54,12 @@ install -p -m 755 runc $RPM_BUILD_ROOT/%{_bindir}/runc
|
||||
%{_bindir}/runc
|
||||
|
||||
%changelog
|
||||
* Mon Nov 7 2022 zhongjiawei<zhongjiawei1@huawei.com> - 1.1.3-6
|
||||
- Type:bugfix
|
||||
- CVE:NA
|
||||
- SUG:NA
|
||||
- DESC:runc log forward to syslog
|
||||
|
||||
* Fri Nov 4 2022 zhongjiawei<zhongjiawei1@huawei.com> - 1.1.3-5
|
||||
- Type:bugfix
|
||||
- CVE:NA
|
||||
|
||||
@ -26,3 +26,4 @@ patch/0025-runc-support-set-cpuset.prefer_cpus-using-cpuset-cpu.patch
|
||||
patch/0026-runc-add-DT-for-cpuset.preferred_cpus-setting.patch
|
||||
patch/0027-runc-modify-runc-Makefile.patch
|
||||
patch/0028-runc-cgroup-apply-method-modify.patch
|
||||
patch/0029-runc-runc-log-forward-to-syslog.patch
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user