Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cni-plugin/pkg/ipamplugin/ipam_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,6 @@ func cmdDel(args *skel.CmdArgs) error {
})

logger.Info("Releasing address using handleID")
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 90*time.Second)
defer cancel()

// Acquire a best-effort host-wide lock to prevent multiple copies of the CNI plugin trying to assign/delete
// concurrently. ReleaseXXX is concurrency safe already but serialising the CNI plugins means that
Expand All @@ -445,6 +442,10 @@ func cmdDel(args *skel.CmdArgs) error {
unlock := acquireIPAMLockBestEffort(conf.IPAMLockFile)
defer unlock()

ctx := context.Background()
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timeout initialization should include an explanatory comment similar to the one in the ADD operations (lines 183-184 and 284-285). This comment explains why the timeout is started after acquiring the lock. Consider adding: "Only start the timeout after we get the lock. When there's a thundering herd of pod deletions, acquiring the lock can take a while."

Suggested change
ctx := context.Background()
ctx := context.Background()
// Only start the timeout after we get the lock. When there's a thundering herd of pod deletions, acquiring the lock can take a while.

Copilot uses AI. Check for mistakes.
ctx, cancel := context.WithTimeout(ctx, 90*time.Second)
defer cancel()

if err := calicoClient.IPAM().ReleaseByHandle(ctx, handleID); err != nil {
if _, ok := err.(errors.ErrorResourceDoesNotExist); !ok {
logger.WithError(err).Error("Failed to release address")
Expand Down
Loading