mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-17 07:30:13 +01:00
Fix incorrect areas of merge
This commit is contained in:
parent
18c5bc3f0f
commit
4fb0c8ed0e
1 changed files with 29 additions and 16 deletions
|
|
@ -79,6 +79,11 @@ func Update(client container.Client, params types.UpdateParams) error {
|
||||||
lifecycle.ExecutePreChecks(client, params)
|
lifecycle.ExecutePreChecks(client, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
containers, err := client.ListContainers(params.Filter)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
containersToUpdate := []container.Container{}
|
containersToUpdate := []container.Container{}
|
||||||
if !params.MonitorOnly {
|
if !params.MonitorOnly {
|
||||||
for i := len(containers) - 1; i >= 0; i-- {
|
for i := len(containers) - 1; i >= 0; i-- {
|
||||||
|
|
@ -91,6 +96,9 @@ func Update(client container.Client, params types.UpdateParams) error {
|
||||||
//shared map for independent and linked update
|
//shared map for independent and linked update
|
||||||
imageIDs := make(map[string]bool)
|
imageIDs := make(map[string]bool)
|
||||||
|
|
||||||
|
if params.RollingRestart {
|
||||||
|
performRollingRestart(containersToUpdate, client, params)
|
||||||
|
} else {
|
||||||
dependencySortedGraphs, err := PrepareContainerList(client, params)
|
dependencySortedGraphs, err := PrepareContainerList(client, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -100,13 +108,10 @@ func Update(client container.Client, params types.UpdateParams) error {
|
||||||
for _, dependencyGraph:= range dependencySortedGraphs {
|
for _, dependencyGraph:= range dependencySortedGraphs {
|
||||||
stopContainersInReversedOrder(dependencyGraph, client, params)
|
stopContainersInReversedOrder(dependencyGraph, client, params)
|
||||||
restartContainersInSortedOrder(dependencyGraph, client, params, imageIDs)
|
restartContainersInSortedOrder(dependencyGraph, client, params, imageIDs)
|
||||||
}
|
|
||||||
|
|
||||||
//clean up outside after containers updated
|
//clean up after containers updated
|
||||||
if params.Cleanup {
|
if params.Cleanup {
|
||||||
for imageID := range imageIDs {
|
cleanupImages(client,imageIDs)
|
||||||
if err := client.RemoveImageByID(imageID); err != nil {
|
|
||||||
log.Error(err)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -166,8 +171,16 @@ func restartContainersInSortedOrder(containers []container.Container, client con
|
||||||
if !container.Stale {
|
if !container.Stale {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
restartStaleContainer(staleContainer, client, params)
|
restartStaleContainer(container, client, params)
|
||||||
imageIDs[staleContainer.ImageID()] = true
|
imageIDs[container.ImageID()] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func cleanupImages(client container.Client, imageIDs map[string]bool) {
|
||||||
|
for imageID := range imageIDs {
|
||||||
|
if err := client.RemoveImageByID(imageID); err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue