address code review comments

This commit is contained in:
Mahmood Ali 2019-09-16 10:40:56 -04:00
parent 2a63caafba
commit c01c6de481
3 changed files with 7 additions and 4 deletions

View file

@ -309,6 +309,10 @@ CREATE:
// the container is started // the container is started
runningContainer, err := client.InspectContainer(container.ID) runningContainer, err := client.InspectContainer(container.ID)
if err != nil { if err != nil {
client.RemoveContainer(docker.RemoveContainerOptions{
ID: container.ID,
Force: true,
})
msg := "failed to inspect started container" msg := "failed to inspect started container"
d.logger.Error(msg, "error", err) d.logger.Error(msg, "error", err)
client.RemoveContainer(docker.RemoveContainerOptions{ client.RemoveContainer(docker.RemoveContainerOptions{

View file

@ -70,7 +70,8 @@ func (d *Driver) removeDanglingContainersIteration() error {
return nil 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) { func (d *Driver) untrackedContainers(tracked map[string]bool, creationTimeout time.Duration) ([]string, error) {
result := []string{} result := []string{}
@ -116,7 +117,7 @@ func (d *Driver) isNomadContainer(c docker.APIContainers) bool {
} }
// double check before killing process // 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() defer cancel()
ci, err := client.InspectContainerWithContext(c.ID, ctx) ci, err := client.InspectContainerWithContext(c.ID, ctx)

View file

@ -111,8 +111,6 @@ func TestDanglingContainerRemoval(t *testing.T) {
err = client.StartContainer(c.ID, nil) err = client.StartContainer(c.ID, nil)
require.NoError(t, err) require.NoError(t, err)
time.Sleep(1 * time.Second)
dd := d.Impl().(*Driver) dd := d.Impl().(*Driver)
trackedContainers := map[string]bool{handle.containerID: true} trackedContainers := map[string]bool{handle.containerID: true}