Skip to content

Commit

Permalink
changelog + docker GC cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dadgar committed Apr 14, 2016
1 parent 3703ff4 commit 6e609fc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 33 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ BUG FIXES:
* core: Prevent garbage collection of running batch jobs [GH-989]
* core: Fix drained, batched allocations from being migrated indefinitely
[GH-1086]
* client: Garbage collect Docker containers on exit [GH-1071]
* client: Fix common exec failures on CentOS and Amazon Linux [GH-1009]

## 0.3.1 (Mars 16, 2016)
Expand Down
54 changes: 25 additions & 29 deletions client/driver/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,18 @@ type dockerPID struct {
}

type DockerHandle struct {
pluginClient *plugin.Client
executor executor.Executor
client *docker.Client
logger *log.Logger
cleanupContainer bool
cleanupImage bool
imageID string
containerID string
version string
killTimeout time.Duration
maxKillTimeout time.Duration
waitCh chan *cstructs.WaitResult
doneCh chan struct{}
pluginClient *plugin.Client
executor executor.Executor
client *docker.Client
logger *log.Logger
cleanupImage bool
imageID string
containerID string
version string
killTimeout time.Duration
maxKillTimeout time.Duration
waitCh chan *cstructs.WaitResult
doneCh chan struct{}
}

func NewDockerDriver(ctx *DriverContext) Driver {
Expand Down Expand Up @@ -617,7 +616,6 @@ func (d *DockerDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle
return nil, err
}

cleanupContainer := d.config.ReadBoolDefault("docker.cleanup.container", true)
cleanupImage := d.config.ReadBoolDefault("docker.cleanup.image", true)

taskDir, ok := ctx.AllocDir.TaskDirs[d.DriverContext.taskName]
Expand Down Expand Up @@ -745,19 +743,18 @@ func (d *DockerDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle
// Return a driver handle
maxKill := d.DriverContext.config.MaxKillTimeout
h := &DockerHandle{
client: client,
executor: exec,
pluginClient: pluginClient,
cleanupContainer: cleanupContainer,
cleanupImage: cleanupImage,
logger: d.logger,
imageID: dockerImage.ID,
containerID: container.ID,
version: d.config.Version,
killTimeout: GetKillTimeout(task.KillTimeout, maxKill),
maxKillTimeout: maxKill,
doneCh: make(chan struct{}),
waitCh: make(chan *cstructs.WaitResult, 1),
client: client,
executor: exec,
pluginClient: pluginClient,
cleanupImage: cleanupImage,
logger: d.logger,
imageID: dockerImage.ID,
containerID: container.ID,
version: d.config.Version,
killTimeout: GetKillTimeout(task.KillTimeout, maxKill),
maxKillTimeout: maxKill,
doneCh: make(chan struct{}),
waitCh: make(chan *cstructs.WaitResult, 1),
}
if err := exec.SyncServices(consulContext(d.config, container.ID)); err != nil {
d.logger.Printf("[ERR] driver.docker: error registering services with consul for task: %q: %v", task.Name, err)
Expand All @@ -767,7 +764,6 @@ func (d *DockerDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle
}

func (d *DockerDriver) Open(ctx *ExecContext, handleID string) (DriverHandle, error) {
cleanupContainer := d.config.ReadBoolDefault("docker.cleanup.container", true)
cleanupImage := d.config.ReadBoolDefault("docker.cleanup.image", true)

// Split the handle
Expand Down Expand Up @@ -942,7 +938,7 @@ func (h *DockerHandle) run() {
// Cleanup the image
if h.cleanupImage {
if err := h.client.RemoveImage(h.imageID); err != nil {
h.logger.Printf("[ERR] driver.docker: error removing image: %v", err)
h.logger.Printf("[DEBUG] driver.docker: error removing image: %v", err)
}
}
}
4 changes: 0 additions & 4 deletions website/source/docs/drivers/docker.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,6 @@ options](/docs/agent/config.html#options):
the docker daemon. `docker.endpoint` must also be specified or this setting
will be ignored.

* `docker.cleanup.container` Defaults to `true`. Changing this to `false` will
prevent Nomad from removing containers from stopped tasks.

* `docker.cleanup.image` Defaults to `true`. Changing this to `false` will
prevent Nomad from removing images from stopped tasks.

Expand All @@ -309,7 +306,6 @@ An example is given below:
```
client {
options = {
"docker.cleanup.container" = "false"
"docker.cleanup.image" = "false"
}
}
Expand Down

0 comments on commit 6e609fc

Please sign in to comment.