Better error reporting in engine logs and unit tests

This commit is contained in:
Solomon Hykes 2013-10-27 07:16:32 +00:00
parent 434f06d03d
commit d3f074494a
3 changed files with 9 additions and 4 deletions

View file

@ -183,7 +183,7 @@ func GetTestImage(runtime *Runtime) *Image {
return image
}
}
log.Fatalf("Test image %v not found", unitTestImageID)
log.Fatalf("Test image %v not found in %s: %s", unitTestImageID, runtime.graph.Root, imgs)
return nil
}

View file

@ -40,6 +40,7 @@ func init() {
// Only one api server can run at the same time - this is enforced by a pidfile.
// The signals SIGINT, SIGKILL and SIGTERM are intercepted for cleanup.
func jobInitApi(job *engine.Job) string {
job.Logf("Creating server")
srv, err := NewServer(job.Eng, ConfigFromJob(job))
if err != nil {
return err.Error()
@ -50,6 +51,7 @@ func jobInitApi(job *engine.Job) string {
log.Fatal(err)
}
}
job.Logf("Setting up signal traps")
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, os.Kill, os.Signal(syscall.SIGTERM))
go func() {
@ -1288,7 +1290,7 @@ func (srv *Server) RegisterLinks(name string, hostConfig *HostConfig) error {
return fmt.Errorf("No such container: %s", name)
}
if hostConfig.Links != nil {
if hostConfig != nil && hostConfig.Links != nil {
for _, l := range hostConfig.Links {
parts, err := parseLink(l)
if err != nil {
@ -1317,11 +1319,14 @@ func (srv *Server) RegisterLinks(name string, hostConfig *HostConfig) error {
}
func (srv *Server) ContainerStart(job *engine.Job) string {
job.Logf("srv engine = %s", srv.Eng.Root())
job.Logf("job engine = %s", job.Eng.Root())
if len(job.Args) < 1 {
return fmt.Sprintf("Usage: %s container_id", job.Name)
}
name := job.Args[0]
runtime := srv.runtime
job.Logf("loading containers from %s", runtime.repository)
container := runtime.Get(name)
if container == nil {
return fmt.Sprintf("No such container: %s", name)

View file

@ -41,11 +41,11 @@ func mkRuntime(f utils.Fataler) *Runtime {
func mkServerFromEngine(eng *engine.Engine, t utils.Fataler) *Server {
iSrv := eng.Hack_GetGlobalVar("httpapi.server")
if iSrv == nil {
t.Fatal("Legacy server field not set in engine")
panic("Legacy server field not set in engine")
}
srv, ok := iSrv.(*Server)
if !ok {
t.Fatal("Legacy server field in engine does not cast to *Server")
panic("Legacy server field in engine does not cast to *Server")
}
return srv
}