From 4d17cf1a296c88bfec41983b634033d8d95ce0d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nils=20m=C3=A5s=C3=A9n?= Date: Sun, 20 Dec 2020 18:16:32 +0100 Subject: [PATCH] fix cleanup for rolling updates (#706) --- internal/actions/update.go | 1 + internal/actions/update_test.go | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/internal/actions/update.go b/internal/actions/update.go index 61f6433..e37e671 100644 --- a/internal/actions/update.go +++ b/internal/actions/update.go @@ -73,6 +73,7 @@ func performRollingRestart(containers []container.Container, client container.Cl if containers[i].Stale { stopStaleContainer(containers[i], client, params) restartStaleContainer(containers[i], client, params) + cleanupImageIDs[containers[i].ImageID()] = true } } diff --git a/internal/actions/update_test.go b/internal/actions/update_test.go index d599cde..1a53aad 100644 --- a/internal/actions/update_test.go +++ b/internal/actions/update_test.go @@ -80,6 +80,14 @@ var _ = Describe("the update action", func() { Expect(client.TestData.TriedToRemoveImageCount).To(Equal(2)) }) }) + When("performing a rolling restart update", func() { + It("should try to remove the image once", func() { + + err := actions.Update(client, types.UpdateParams{Cleanup: true, RollingRestart: true}) + Expect(err).NotTo(HaveOccurred()) + Expect(client.TestData.TriedToRemoveImageCount).To(Equal(1)) + }) + }) }) When("watchtower has been instructed to monitor only", func() {