Fix disconnectNetwork container ID matching

Problem

When FF_NETWORK_PER_BUILD is enabled on Windows runners, ~5% of jobs fail during Fetching changes with connection timeouts. The root cause is stale HNS (Host Networking Service) endpoints accumulating because disconnectNetwork failed to disconnect containers referenced by ID, which is the path the per-build cleanup uses.

Root Cause

In disconnectNetwork, the code iterates over network.Containers which is a map[string]network.EndpointResource. The map key is the container ID, but the code was comparing against pluggedContainer.Name:

// Before: compares ID to Name - never matches
for _, pluggedContainer := range network.Containers {
    if id == pluggedContainer.Name {

Since the condition only matched containers by name, callers passing a container ID (such as in the FF_NETWORK_PER_BUILD cleanup path) were never disconnected.

Solution

This MR fixes the function, and adds tests to ensure it won't break in the future.

#39382

Edited by Daniel Keenan

Merge request reports

Loading