Skip to content

Commit 3bd2ae2

Browse files
aauschclaude
authored andcommitted
fix(nebulagraph): retry network removal on active endpoints race
After container termination, Docker may not have fully disconnected endpoints from the network yet. The moby client surfaces this as "has active endpoints" on NetworkRemove. This race was latent with the old docker/docker client but is now consistently triggered. Retry up to 3 times with a 500ms delay when the error indicates active endpoints remain. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d95b4e7 commit 3bd2ae2

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

modules/nebulagraph/nebulagraph.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"strings"
8+
"time"
79

810
"github.com/testcontainers/testcontainers-go"
911
"github.com/testcontainers/testcontainers-go/network"
@@ -119,8 +121,19 @@ func terminateContainersAndRemoveNetwork(ctx context.Context, netRes *testcontai
119121
}
120122
}
121123

122-
if err := netRes.Remove(ctx); err != nil {
124+
// Retry network removal: after container termination, Docker may not
125+
// have fully disconnected endpoints yet, causing "has active endpoints".
126+
for range 3 {
127+
err := netRes.Remove(ctx)
128+
if err == nil {
129+
break
130+
}
131+
if strings.Contains(err.Error(), "has active endpoints") {
132+
time.Sleep(500 * time.Millisecond)
133+
continue
134+
}
123135
errs = append(errs, fmt.Errorf("network remove: %w", err))
136+
break
124137
}
125138

126139
return errs

0 commit comments

Comments
 (0)