environment(docker): improve logging and stacks

This commit is contained in:
Matthew Penner
2023-01-17 11:47:27 -07:00
parent e74d8e3501
commit 9b8b3c90fb
6 changed files with 12 additions and 9 deletions

View File

@@ -58,7 +58,7 @@ func (e *Environment) Attach(ctx context.Context) error {
// Set the stream again with the container.
if st, err := e.client.ContainerAttach(ctx, e.Id, opts); err != nil {
return err
return errors.WrapIf(err, "environment/docker: error while attaching to container")
} else {
e.SetStream(&st)
}
@@ -143,7 +143,7 @@ func (e *Environment) Create() error {
if _, err := e.ContainerInspect(ctx); err == nil {
return nil
} else if !client.IsErrNotFound(err) {
return errors.Wrap(err, "environment/docker: failed to inspect container")
return errors.WrapIf(err, "environment/docker: failed to inspect container")
}
// Try to pull the requested image before creating the container.

View File

@@ -161,7 +161,7 @@ func (e *Environment) ExitState() (uint32, bool, error) {
if client.IsErrNotFound(err) {
return 1, false, nil
}
return 0, false, err
return 0, false, errors.WrapIf(err, "environment/docker: failed to inspect container")
}
return uint32(c.State.ExitCode), c.State.OOMKilled, nil
}

View File

@@ -103,7 +103,7 @@ func (e *Environment) Start(ctx context.Context) error {
// exists on the system, and rebuild the container if that is required for server booting to
// occur.
if err := e.OnBeforeStart(ctx); err != nil {
return errors.WithStackIf(err)
return errors.WrapIf(err, "environment/docker: failed to run pre-boot process")
}
// If we cannot start & attach to the container in 30 seconds something has gone
@@ -119,7 +119,7 @@ func (e *Environment) Start(ctx context.Context) error {
// By explicitly attaching to the instance before we start it, we can immediately
// react to errors/output stopping/etc. when starting.
if err := e.Attach(actx); err != nil {
return err
return errors.WrapIf(err, "environment/docker: failed to attach to container")
}
if err := e.client.ContainerStart(actx, e.Id, types.ContainerStartOptions{}); err != nil {