mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-16 23:20:12 +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)
|
||||
}
|
||||
|
||||
containers, err := client.ListContainers(params.Filter)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
containersToUpdate := []container.Container{}
|
||||
if !params.MonitorOnly {
|
||||
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
|
||||
imageIDs := make(map[string]bool)
|
||||
|
||||
if params.RollingRestart {
|
||||
performRollingRestart(containersToUpdate, client, params)
|
||||
} else {
|
||||
dependencySortedGraphs, err := PrepareContainerList(client, params)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -100,13 +108,10 @@ func Update(client container.Client, params types.UpdateParams) error {
|
|||
for _, dependencyGraph:= range dependencySortedGraphs {
|
||||
stopContainersInReversedOrder(dependencyGraph, client, params)
|
||||
restartContainersInSortedOrder(dependencyGraph, client, params, imageIDs)
|
||||
}
|
||||
|
||||
//clean up outside after containers updated
|
||||
//clean up after containers updated
|
||||
if params.Cleanup {
|
||||
for imageID := range imageIDs {
|
||||
if err := client.RemoveImageByID(imageID); err != nil {
|
||||
log.Error(err)
|
||||
cleanupImages(client,imageIDs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -166,8 +171,16 @@ func restartContainersInSortedOrder(containers []container.Container, client con
|
|||
if !container.Stale {
|
||||
continue
|
||||
}
|
||||
restartStaleContainer(staleContainer, client, params)
|
||||
imageIDs[staleContainer.ImageID()] = true
|
||||
restartStaleContainer(container, client, params)
|
||||
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