From 48d0706a497b5be36baa491650560db3f4868fc3 Mon Sep 17 00:00:00 2001 From: Mrunal Patel Date: Mon, 25 Sep 2017 15:31:00 -0700 Subject: [PATCH] Add log size max flag to conmon and pass it on container create Signed-off-by: Mrunal Patel --- conmon/conmon.c | 4 ++++ oci/oci.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/conmon/conmon.c b/conmon/conmon.c index 006ba141..85a0def3 100644 --- a/conmon/conmon.c +++ b/conmon/conmon.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -20,6 +21,7 @@ #include #include #include +#include #include #include @@ -107,6 +109,7 @@ static bool opt_exec = false; static char *opt_log_path = NULL; static char *opt_exit_dir = NULL; static int opt_timeout = 0; +static int64_t opt_log_size_max = -1; static GOptionEntry opt_entries[] = { { "terminal", 't', 0, G_OPTION_ARG_NONE, &opt_terminal, "Terminal", NULL }, @@ -122,6 +125,7 @@ static GOptionEntry opt_entries[] = { "exit-dir", 0, 0, G_OPTION_ARG_STRING, &opt_exit_dir, "Path to the directory where exit files are written", NULL }, { "log-path", 'l', 0, G_OPTION_ARG_STRING, &opt_log_path, "Log file path", NULL }, { "timeout", 'T', 0, G_OPTION_ARG_INT, &opt_timeout, "Timeout in seconds", NULL }, + { "log-size-max", 0, 0, G_OPTION_ARG_INT64, &opt_log_size_max, "Maximum size of log file", NULL }, { NULL } }; diff --git a/oci/oci.go b/oci/oci.go index e11c8cb4..ab8383b9 100644 --- a/oci/oci.go +++ b/oci/oci.go @@ -158,6 +158,9 @@ func (r *Runtime) CreateContainer(c *Container, cgroupParent string) error { args = append(args, "-p", filepath.Join(c.bundlePath, "pidfile")) args = append(args, "-l", c.logPath) args = append(args, "--exit-dir", r.containerExitsDir) + if r.logSizeMax >= 0 { + args = append(args, "--log-size-max", fmt.Sprintf("%v", r.logSizeMax)) + } if c.terminal { args = append(args, "-t") } else if c.stdin {