fix: linked/depends-on container restarting (#1103)

This commit is contained in:
nils måsén 2022-01-11 17:15:22 +01:00 committed by GitHub
parent aa02d8d31b
commit 084249c5fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 358 additions and 21 deletions

View file

@ -20,6 +20,7 @@ var _ = Describe("the update action", func() {
BeforeEach(func() {
pullImages := false
removeVolumes := false
//goland:noinspection GoBoolExpressions
client = CreateMockClient(
&TestData{
NameOfContainerToKeep: "test-container-02",
@ -255,6 +256,54 @@ var _ = Describe("the update action", func() {
})
})
When("container is linked to restarting containers", func() {
It("should be marked for restart", func() {
provider := CreateMockContainerWithConfig(
"test-container-provider",
"/test-container-provider",
"fake-image2:latest",
true,
false,
time.Now(),
&dockerContainer.Config{
Labels: map[string]string{},
ExposedPorts: map[nat.Port]struct{}{},
})
provider.Stale = true
consumer := CreateMockContainerWithConfig(
"test-container-consumer",
"/test-container-consumer",
"fake-image3:latest",
true,
false,
time.Now(),
&dockerContainer.Config{
Labels: map[string]string{
"com.centurylinklabs.watchtower.depends-on": "test-container-provider",
},
ExposedPorts: map[nat.Port]struct{}{},
})
containers := []container.Container{
provider,
consumer,
}
Expect(provider.ToRestart()).To(BeTrue())
Expect(consumer.ToRestart()).To(BeFalse())
actions.UpdateImplicitRestart(containers)
Expect(containers[0].ToRestart()).To(BeTrue())
Expect(containers[1].ToRestart()).To(BeTrue())
})
})
When("container is not running", func() {
BeforeEach(func() {
client = CreateMockClient(