mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 02:15:43 +03:00
Delete on increment and add a safety guard
This commit is contained in:
@@ -203,6 +203,7 @@ func (d *dockerCoordinator) IncrementImageReference(id, image string) {
|
||||
if cancel, ok := d.deleteFuture[id]; ok {
|
||||
d.logger.Printf("[DEBUG] driver.docker: cancelling removal of image %q", image)
|
||||
cancel()
|
||||
delete(d.deleteFuture, id)
|
||||
}
|
||||
d.imageLock.Unlock()
|
||||
}
|
||||
@@ -229,6 +230,13 @@ func (d *dockerCoordinator) RemoveImage(id string) {
|
||||
return
|
||||
}
|
||||
|
||||
// This should never be the case but we safefty guard so we don't leak a
|
||||
// cancel.
|
||||
if cancel, ok := d.deleteFuture[id]; ok {
|
||||
d.logger.Printf("[ERR] driver.docker: image id %q has lingering delete future", id)
|
||||
cancel()
|
||||
}
|
||||
|
||||
// Setup a future to delete the image
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
d.deleteFuture[id] = cancel
|
||||
|
||||
Reference in New Issue
Block a user