Skip to content

fix: prevent stale peer removal in PeerRemovalQueue - #132

Merged
synackd merged 1 commit into
mainfrom
pr/a-peer-removal-queue-fix
Sep 8, 2026
Merged

synackd merged 1 commit into
mainfrom
pr/a-peer-removal-queue-fix

Conversation

@synackd

@synackd synackd commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR addresses a race condition in the PeerRemovalQueue where a removal job could be processed after a node had re‑connected and its public key changed. The queue now stores the peer's public key at enqueue time and validates it against the current key before invoking RemovePeer. If the keys differ, the stale removal is skipped and a warning is logged. Added a new removalJob struct to carry the key, updated the queue logic, and introduced comprehensive unit tests (TestPeerRemovalQueueStaleRemovalSkipped and TestPeerRemovalQueueConcurrentEnqueue) to verify correct behavior. This improves reliability of WireGuard peer management during rapid reconnect scenarios.

Fixes #128 (comment)

Checklist

  • My code follows the style guidelines of this project
  • I have added/updated comments where needed
  • I have added tests that prove my fix is effective or my feature works
  • I have run make test (or equivalent) locally and all tests pass
  • I have updated the relevant documentation (CLI examples, man pages, README, other docs, etc.)
  • DCO Sign-off: All commits are signed off (git commit -s) with my real name and email
  • REUSE Compliance:
    • Each new/modified source file has SPDX copyright and license headers
    • Any non-commentable files include a <filename>.license sidecar
    • All referenced licenses are present in the LICENSES/ directory

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Dependency update
  • Build system/CI

@synackd
synackd force-pushed the pr/a-peer-removal-queue-fix branch 3 times, most recently from 2394366 to 43fdabf Compare August 31, 2026 16:30
@synackd synackd mentioned this pull request Aug 31, 2026
11 of 15 tasks
@synackd
synackd marked this pull request as ready for review August 31, 2026 16:42
@synackd
synackd force-pushed the pr/a-peer-removal-queue-fix branch 2 times, most recently from 3dca9fc to 52ad10a Compare September 2, 2026 16:56
@synackd

synackd commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

All checks are now passing and this is ready for review.

@synackd

synackd commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Probably will want to merge #134 and rebase this before merging.

Resolve a race condition in the PeerRemovalQueue where a removal job
could be processed after a node had reconnected and its public key
changed. The queue now stores the peer's public key at enqueue time and
validates it against the current key before invoking RemovePeer. If the
keys differ, the stale removal is skipped and a warning is logged. Added
a new removalJob struct to carry the key, updated the queue logic, and
introduced comprehensive unit tests
(TestPeerRemovalQueueStaleRemovalSkipped and
TestPeerRemovalQueueConcurrentEnqueue) to verify correct behavior. This
improves reliability of WireGuard peer management during rapid reconnect
scenarios.

Signed-off-by: Devon Bautista <17506592+synackd@users.noreply.github.com>
@synackd
synackd force-pushed the pr/a-peer-removal-queue-fix branch from 52ad10a to 75b60f0 Compare September 2, 2026 20:18
@synackd
synackd enabled auto-merge (squash) September 8, 2026 15:24
@synackd
synackd merged commit 9c23940 into main Sep 8, 2026
14 checks passed
@synackd
synackd deleted the pr/a-peer-removal-queue-fix branch September 8, 2026 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants