|
|
@ -50,6 +50,7 @@ func Update(client container.Client, params types.UpdateParams) (*metrics2.Metri
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
containers, err = sorter.SortByDependencies(containers)
|
|
|
|
containers, err = sorter.SortByDependencies(containers)
|
|
|
|
|
|
|
|
|
|
|
|
metric.Scanned = len(containers)
|
|
|
|
metric.Scanned = len(containers)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
@ -57,11 +58,11 @@ func Update(client container.Client, params types.UpdateParams) (*metrics2.Metri
|
|
|
|
|
|
|
|
|
|
|
|
checkDependencies(containers)
|
|
|
|
checkDependencies(containers)
|
|
|
|
|
|
|
|
|
|
|
|
containersToUpdate := []container.Container{}
|
|
|
|
var containersToUpdate []container.Container
|
|
|
|
if !params.MonitorOnly {
|
|
|
|
if !params.MonitorOnly {
|
|
|
|
for i := len(containers) - 1; i >= 0; i-- {
|
|
|
|
for _, c := range containers {
|
|
|
|
if !containers[i].IsMonitorOnly() {
|
|
|
|
if !c.IsMonitorOnly() {
|
|
|
|
containersToUpdate = append(containersToUpdate, containers[i])
|
|
|
|
containersToUpdate = append(containersToUpdate, c)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -86,7 +87,7 @@ func performRollingRestart(containers []container.Container, client container.Cl
|
|
|
|
failed := 0
|
|
|
|
failed := 0
|
|
|
|
|
|
|
|
|
|
|
|
for i := len(containers) - 1; i >= 0; i-- {
|
|
|
|
for i := len(containers) - 1; i >= 0; i-- {
|
|
|
|
if containers[i].Stale {
|
|
|
|
if containers[i].ToRestart() {
|
|
|
|
if err := stopStaleContainer(containers[i], client, params); err != nil {
|
|
|
|
if err := stopStaleContainer(containers[i], client, params); err != nil {
|
|
|
|
failed++
|
|
|
|
failed++
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -119,7 +120,7 @@ func stopStaleContainer(container container.Container, client container.Client,
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if !container.Stale {
|
|
|
|
if !container.ToRestart() {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if params.LifecycleHooks {
|
|
|
|
if params.LifecycleHooks {
|
|
|
@ -143,7 +144,7 @@ func restartContainersInSortedOrder(containers []container.Container, client con
|
|
|
|
failed := 0
|
|
|
|
failed := 0
|
|
|
|
|
|
|
|
|
|
|
|
for _, c := range containers {
|
|
|
|
for _, c := range containers {
|
|
|
|
if !c.Stale {
|
|
|
|
if !c.ToRestart() {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err := restartStaleContainer(c, client, params); err != nil {
|
|
|
|
if err := restartStaleContainer(c, client, params); err != nil {
|
|
|
@ -183,7 +184,7 @@ func restartStaleContainer(container container.Container, client container.Clien
|
|
|
|
if newContainerID, err := client.StartContainer(container); err != nil {
|
|
|
|
if newContainerID, err := client.StartContainer(container); err != nil {
|
|
|
|
log.Error(err)
|
|
|
|
log.Error(err)
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
} else if container.Stale && params.LifecycleHooks {
|
|
|
|
} else if container.ToRestart() && params.LifecycleHooks {
|
|
|
|
lifecycle.ExecutePostUpdateCommand(client, newContainerID)
|
|
|
|
lifecycle.ExecutePostUpdateCommand(client, newContainerID)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -192,16 +193,19 @@ func restartStaleContainer(container container.Container, client container.Clien
|
|
|
|
|
|
|
|
|
|
|
|
func checkDependencies(containers []container.Container) {
|
|
|
|
func checkDependencies(containers []container.Container) {
|
|
|
|
|
|
|
|
|
|
|
|
for i, parent := range containers {
|
|
|
|
for _, c := range containers {
|
|
|
|
if parent.ToRestart() {
|
|
|
|
if c.ToRestart() {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LinkLoop:
|
|
|
|
LinkLoop:
|
|
|
|
for _, linkName := range parent.Links() {
|
|
|
|
for _, linkName := range c.Links() {
|
|
|
|
for _, child := range containers {
|
|
|
|
for _, candidate := range containers {
|
|
|
|
if child.Name() == linkName && child.ToRestart() {
|
|
|
|
if candidate.Name() != linkName {
|
|
|
|
containers[i].Linked = true
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if candidate.ToRestart() {
|
|
|
|
|
|
|
|
c.LinkedToRestarting = true
|
|
|
|
break LinkLoop
|
|
|
|
break LinkLoop
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|