mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 19:13:34 +00:00
chore: global reconciliation: stop all running conflicting containers, not only replace the first one
This commit is contained in:
@@ -301,6 +301,23 @@ func reconcileGlobalContainer(
|
||||
}
|
||||
|
||||
if containerToReplace != nil {
|
||||
// Stop any other running containers that have conflicting ports before replacing the container.
|
||||
// This handles the edge case where multiple running containers exist (due to bugs or interrupted deployments)
|
||||
// and more than one has ports that conflict with the new spec.
|
||||
for _, c := range containers {
|
||||
if c.Container.ID == containerToReplace.Container.ID || !c.Container.State.Running {
|
||||
continue
|
||||
}
|
||||
conflictingPorts, err := c.Container.ConflictingServicePorts(spec.Ports)
|
||||
if err != nil || len(conflictingPorts) > 0 {
|
||||
ops = append(ops, &StopContainerOperation{
|
||||
ServiceID: serviceID,
|
||||
ContainerID: c.Container.ID,
|
||||
MachineID: machineID,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Replace the running container with a new one.
|
||||
order := determineUpdateOrder(containerToReplace.Container, spec)
|
||||
ops = append(ops, &ReplaceContainerOperation{
|
||||
|
||||
Reference in New Issue
Block a user