From 72c08e0591e4a0eaa5a737e7e9bc2911993cd728 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Wed, 13 May 2020 11:17:47 -0400 Subject: [PATCH] docker: Fix docker image gc tracking This fixes a bug where docker images may not be GCed. The cause of the bug is that we track the task using `task.ID+task.Name` on task start but remove on plain `task.ID`. This haromize the two paths by using `task.ID`, as it's unique enough and it's also used in the `loadImage` path (path when loading an image from a local tarball instead of dockerhub). --- drivers/docker/driver.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/docker/driver.go b/drivers/docker/driver.go index 4e6cadb95ac..291b36d3733 100644 --- a/drivers/docker/driver.go +++ b/drivers/docker/driver.go @@ -519,8 +519,6 @@ func (d *Driver) createImage(task *drivers.TaskConfig, driverConfig *TaskConfig, image := driverConfig.Image repo, tag := parseDockerImage(image) - callerID := fmt.Sprintf("%s-%s", task.ID, task.Name) - // We're going to check whether the image is already downloaded. If the tag // is "latest", or ForcePull is set, we have to check for a new version every time so we don't // bother to check and cache the id here. We'll download first, then cache. @@ -529,7 +527,7 @@ func (d *Driver) createImage(task *drivers.TaskConfig, driverConfig *TaskConfig, } else if tag != "latest" { if dockerImage, _ := client.InspectImage(image); dockerImage != nil { // Image exists so just increment its reference count - d.coordinator.IncrementImageReference(dockerImage.ID, image, callerID) + d.coordinator.IncrementImageReference(dockerImage.ID, image, task.ID) return dockerImage.ID, nil } }