From 0a0891180039162eb10c4ab6e52cac143ec4c5bc Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 5 Aug 2021 04:17:37 -0400 Subject: [PATCH] fix: do not aggressively clean up when using the docker-local scheduler --- plugins/registry/functions.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/plugins/registry/functions.go b/plugins/registry/functions.go index 991981248..3b5ecf13a 100644 --- a/plugins/registry/functions.go +++ b/plugins/registry/functions.go @@ -78,9 +78,15 @@ func pushToRegistry(appName string, tag int, imageID string, imageRepo string) e return errors.New("Unable to push image") } - common.LogVerboseQuiet("Cleaning up") - imageCleanup(appName, fmt.Sprintf("%s%s", registryServer, imageRepo), imageTag, tag) - imageCleanup(appName, imageRepo, imageTag, tag) + // Only clean up when the scheduler is not docker-local + // other schedulers do not retire local images + if common.GetAppScheduler(appName) != "docker-local" { + common.LogVerboseQuiet("Cleaning up") + imageCleanup(appName, fmt.Sprintf("%s%s", registryServer, imageRepo), imageTag, tag) + if fmt.Sprintf("%s%s", registryServer, imageRepo) != imageRepo { + imageCleanup(appName, imageRepo, imageTag, tag) + } + } common.LogVerboseQuiet(fmt.Sprintf("Image %s pushed", fullImage)) return nil @@ -110,12 +116,11 @@ func dockerPush(imageTag string) bool { func imageCleanup(appName string, imageRepo string, imageTag string, tag int) { // # keep last two images in place - oldTag := tag - 1 + oldTag := tag - 2 tenImagesAgoTag := tag - 12 imagesToRemove := []string{} for oldTag > 0 { - common.LogInfo1(fmt.Sprintf("Removing image: %s:%d", imageRepo, oldTag)) imagesToRemove = append(imagesToRemove, fmt.Sprintf("%s:%d", imageRepo, oldTag)) oldTag = oldTag - 1 if tenImagesAgoTag == oldTag {