mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-13 21:56:38 +01:00
feat: ignore removal error due to non-existing containers (#1481)
Co-authored-by: nils måsén <nils@piksel.se> Fixes https://github.com/containrrr/watchtower/issues/1480
This commit is contained in:
parent
a4d00bfd75
commit
3190ce2df1
3 changed files with 115 additions and 12 deletions
|
|
@ -1,6 +1,8 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/containrrr/watchtower/pkg/container/mocks"
|
||||
"github.com/containrrr/watchtower/pkg/filters"
|
||||
t "github.com/containrrr/watchtower/pkg/types"
|
||||
|
|
@ -69,6 +71,38 @@ var _ = Describe("the client", func() {
|
|||
})
|
||||
})
|
||||
})
|
||||
When("removing a running container", func() {
|
||||
When("the container still exist after stopping", func() {
|
||||
It("should attempt to remove the container", func() {
|
||||
container := *MockContainer(WithContainerState(types.ContainerState{Running: true}))
|
||||
containerStopped := *MockContainer(WithContainerState(types.ContainerState{Running: false}))
|
||||
|
||||
cid := container.ContainerInfo().ID
|
||||
mockServer.AppendHandlers(
|
||||
mocks.KillContainerHandler(cid, mocks.Found),
|
||||
mocks.GetContainerHandler(cid, containerStopped.ContainerInfo()),
|
||||
mocks.RemoveContainerHandler(cid, mocks.Found),
|
||||
mocks.GetContainerHandler(cid, nil),
|
||||
)
|
||||
|
||||
Expect(dockerClient{api: docker}.StopContainer(container, time.Minute)).To(Succeed())
|
||||
})
|
||||
})
|
||||
When("the container does not exist after stopping", func() {
|
||||
It("should not cause an error", func() {
|
||||
container := *MockContainer(WithContainerState(types.ContainerState{Running: true}))
|
||||
|
||||
cid := container.ContainerInfo().ID
|
||||
mockServer.AppendHandlers(
|
||||
mocks.KillContainerHandler(cid, mocks.Found),
|
||||
mocks.GetContainerHandler(cid, nil),
|
||||
mocks.RemoveContainerHandler(cid, mocks.Missing),
|
||||
)
|
||||
|
||||
Expect(dockerClient{api: docker}.StopContainer(container, time.Minute)).To(Succeed())
|
||||
})
|
||||
})
|
||||
})
|
||||
When("listing containers", func() {
|
||||
When("no filter is provided", func() {
|
||||
It("should return all available containers", func() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue