Skip to content

Commit

Permalink
address code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmood Ali committed Sep 16, 2019
1 parent 6a5b262 commit dcf9bcb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 4 additions & 0 deletions drivers/docker/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ CREATE:
// the container is started
runningContainer, err := client.InspectContainer(container.ID)
if err != nil {
client.RemoveContainer(docker.RemoveContainerOptions{
ID: container.ID,
Force: true,
})
msg := "failed to inspect started container"
d.logger.Error(msg, "error", err)
return nil, nil, nstructs.NewRecoverableError(fmt.Errorf("%s %s: %s", msg, container.ID, err), true)
Expand Down
5 changes: 3 additions & 2 deletions drivers/docker/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ func (d *Driver) removeDanglingContainersIteration() error {
return nil
}

// untrackedContainers returns the ids of containers that look
// untrackedContainers returns the ids of containers that suspected
// to have been started by Nomad but aren't tracked by this driver
func (d *Driver) untrackedContainers(tracked map[string]bool, creationTimeout time.Duration) ([]string, error) {
result := []string{}

Expand Down Expand Up @@ -116,7 +117,7 @@ func (d *Driver) isNomadContainer(c docker.APIContainers) bool {
}

// double check before killing process
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
ctx, cancel := context.WithTimeout(d.ctx, 20*time.Second)
defer cancel()

ci, err := client.InspectContainerWithContext(c.ID, ctx)
Expand Down
2 changes: 0 additions & 2 deletions drivers/docker/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ func TestDanglingContainerRemoval(t *testing.T) {
err = client.StartContainer(c.ID, nil)
require.NoError(t, err)

time.Sleep(1 * time.Second)

dd := d.Impl().(*Driver)
trackedContainers := map[string]bool{handle.containerID: true}

Expand Down

0 comments on commit dcf9bcb

Please sign in to comment.