fix(plan): make stop operation formatting consistent and do not count it as removal in summary

This commit is contained in:
Pasha Sviderski
2026-11-03 12:54:57 +10:00
parent ff6ac45e1e
commit 6c7ddeb82f
8 changed files with 48 additions and 5 deletions
+1 -1
View File
@@ -195,8 +195,8 @@ func (sp *ServicePlan) FormatSummary() string {
machines[o.MachineID] = struct{}{}
removeCount++
case *operation.StopContainerOperation:
// Stop operations aren't counted because a later operation in the plan removes the stopped container.
machines[o.MachineID] = struct{}{}
removeCount++
}
}
+10
View File
@@ -25,6 +25,16 @@ func TestServicePlan_FormatSummary(t *testing.T) {
},
expected: "2 update (in place) · across 2 machines",
},
{
name: "stop operations not counted as they are followed by remove",
ops: []operation.Operation{
&operation.StopContainerOperation{MachineID: "m-1"},
&operation.StopContainerOperation{MachineID: "m-1"},
&operation.ReplaceContainerOperation{MachineID: "m-1", Order: api.UpdateOrderStopFirst},
&operation.RemoveContainerOperation{MachineID: "m-1"},
},
expected: "1 replace (stop-first) · 1 remove · across 1 machine",
},
{
name: "all operation types",
ops: []operation.Operation{
+1
View File
@@ -386,6 +386,7 @@ func reconcileGlobalContainer(
if err != nil || len(conflictingPorts) > 0 {
ops = append(ops, &operation.StopContainerOperation{
ServiceID: serviceID,
ServiceName: c.Container.ServiceSpec.Name,
ContainerID: c.Container.ID,
MachineID: machine.Id,
MachineName: machine.Name,
+1
View File
@@ -363,6 +363,7 @@ func TestReconcileGlobalContainer(t *testing.T) {
expectedOps: []operation.Operation{
&operation.StopContainerOperation{
ServiceID: "service-1",
ServiceName: container2WithPort9090.ServiceSpec.Name,
ContainerID: "container-2",
MachineID: "machine-1",
MachineName: "machine-1",