mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-29 04:25:40 +00:00
logging: Add containerID and sandboxID to all log calls
Adding cid+sid fields to the log entries generated by most of the CLI commands will make debugging across the system easier. Fixes #452. Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
@@ -89,6 +89,8 @@ func create(containerID, bundlePath, console, pidFilePath string, detach bool,
|
||||
runtimeConfig oci.RuntimeConfig) error {
|
||||
var err error
|
||||
|
||||
kataLog = kataLog.WithField("container", containerID)
|
||||
|
||||
// Checks the MUST and MUST NOT from OCI runtime specification
|
||||
if bundlePath, err = validCreateParams(containerID, bundlePath); err != nil {
|
||||
return err
|
||||
@@ -238,6 +240,8 @@ func createSandbox(ociSpec oci.CompatOCISpec, runtimeConfig oci.RuntimeConfig,
|
||||
return vc.Process{}, err
|
||||
}
|
||||
|
||||
kataLog = kataLog.WithField("sandbox", sandbox.ID())
|
||||
|
||||
containers := sandbox.GetAllContainers()
|
||||
if len(containers) != 1 {
|
||||
return vc.Process{}, fmt.Errorf("BUG: Container list from sandbox is wrong, expecting only one container, found %d containers", len(containers))
|
||||
@@ -263,6 +267,8 @@ func createContainer(ociSpec oci.CompatOCISpec, containerID, bundlePath,
|
||||
return vc.Process{}, err
|
||||
}
|
||||
|
||||
kataLog = kataLog.WithField("sandbox", sandboxID)
|
||||
|
||||
_, c, err := vci.CreateContainer(sandboxID, contConfig)
|
||||
if err != nil {
|
||||
return vc.Process{}, err
|
||||
|
Reference in New Issue
Block a user