Add log and more context to errors in Create
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
4adf5d2c0d
commit
cf3b72852a
1 changed files with 10 additions and 5 deletions
|
@ -14,6 +14,7 @@ import (
|
|||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/containerd/runtime"
|
||||
"github.com/opencontainers/runc/libcontainer"
|
||||
"github.com/opencontainers/runc/libcontainer/configs"
|
||||
|
@ -355,13 +356,17 @@ func (r *libcontainerRuntime) Create(id, bundlePath string, stdio *runtime.Stdio
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logrus.WithFields(logrus.Fields{
|
||||
"id": id,
|
||||
"bundlePath": bundlePath,
|
||||
}).Debugf("create container")
|
||||
config, err := r.createLibcontainerConfig(id, bundlePath, spec, rspec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
container, err := r.factory.Create(id, config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("create container: %v", err)
|
||||
}
|
||||
process, err := r.newProcess(spec.Process, stdio)
|
||||
if err != nil {
|
||||
|
@ -413,14 +418,14 @@ func (r *libcontainerRuntime) newProcess(p specs.Process, stdio *runtime.Stdio)
|
|||
if stdio.Stdout != "" {
|
||||
f, err := os.OpenFile(stdio.Stdout, os.O_CREATE|os.O_WRONLY, 0755)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("open stdout: %v", err)
|
||||
}
|
||||
stdout = f
|
||||
}
|
||||
if stdio.Stderr != "" {
|
||||
f, err := os.OpenFile(stdio.Stderr, os.O_CREATE|os.O_WRONLY, 0755)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("open stderr: %v", err)
|
||||
}
|
||||
stderr = f
|
||||
}
|
||||
|
@ -458,10 +463,10 @@ func (r *libcontainerRuntime) loadSpec(cPath, rPath string) (spec *specs.LinuxSp
|
|||
defer rf.Close()
|
||||
|
||||
if err = json.NewDecoder(cf).Decode(&spec); err != nil {
|
||||
return spec, rspec, err
|
||||
return spec, rspec, fmt.Errorf("unmarshal %s: %v", cPath, err)
|
||||
}
|
||||
if err = json.NewDecoder(rf).Decode(&rspec); err != nil {
|
||||
return spec, rspec, err
|
||||
return spec, rspec, fmt.Errorf("unmarshal %s: %v", rPath, err)
|
||||
}
|
||||
return spec, rspec, r.checkSpecVersion(spec)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue