diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2019-06-13 14:21:13 +0200 |
---|---|---|
committer | Giuseppe Scrivano <gscrivan@redhat.com> | 2019-06-13 14:21:13 +0200 |
commit | 13e1afdb02592ab4b0e4e7fb936c76f5c7dda20a (patch) | |
tree | dd21a1e14c8895d01cbf8ce8ac193dc33e2f7917 /libpod/oci_linux.go | |
parent | 6e4ce54d33df0c43392fd247d42106802ca556df (diff) | |
download | podman-13e1afdb02592ab4b0e4e7fb936c76f5c7dda20a.tar.gz podman-13e1afdb02592ab4b0e4e7fb936c76f5c7dda20a.tar.bz2 podman-13e1afdb02592ab4b0e4e7fb936c76f5c7dda20a.zip |
oci: allow to specify what runtimes support JSON
add a new configuration `runtime_supports_json` to list what OCI
runtimes support the --log-format=json option. If the runtime is not
listed here, libpod will redirect stdout/stderr from the runtime
process.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'libpod/oci_linux.go')
-rw-r--r-- | libpod/oci_linux.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/libpod/oci_linux.go b/libpod/oci_linux.go index b9820ce9f..9bbefdb06 100644 --- a/libpod/oci_linux.go +++ b/libpod/oci_linux.go @@ -223,7 +223,7 @@ func (r *OCIRuntime) createOCIContainer(ctr *Container, cgroupParent string, res args = append(args, "-b", ctr.bundlePath()) args = append(args, "-p", filepath.Join(ctr.state.RunDir, "pidfile")) args = append(args, "--exit-dir", r.exitsDir) - if logLevel != logrus.DebugLevel { + if logLevel != logrus.DebugLevel && r.supportsJSON { args = append(args, "--runtime-arg", "--log-format=json", "--runtime-arg", "--log", fmt.Sprintf("--runtime-arg=%s", ociLog)) } if ctr.config.ConmonPidFile != "" { @@ -423,11 +423,13 @@ func (r *OCIRuntime) createOCIContainer(ctr *Container, cgroupParent string, res } logrus.Debugf("Received container pid: %d", ss.si.Pid) if ss.si.Pid == -1 { - data, err := ioutil.ReadFile(ociLog) - if err == nil { - var ociErr ociError - if err := json.Unmarshal(data, &ociErr); err == nil { - return errors.Wrapf(ErrOCIRuntime, "%s", strings.Trim(ociErr.Msg, "\n")) + if r.supportsJSON { + data, err := ioutil.ReadFile(ociLog) + if err == nil { + var ociErr ociError + if err := json.Unmarshal(data, &ociErr); err == nil { + return errors.Wrapf(ErrOCIRuntime, "%s", strings.Trim(ociErr.Msg, "\n")) + } } } // If we failed to parse the JSON errors, then print the output as it is |