Skip to content

roles/dhcp: Fix concurrency issues on discover. #2149

Open
romanlum wants to merge 4 commits intoBeryJu:mainfrom
romanlum:dhcp/fix-2148
Open

roles/dhcp: Fix concurrency issues on discover. #2149
romanlum wants to merge 4 commits intoBeryJu:mainfrom
romanlum:dhcp/fix-2148

Conversation

@romanlum
Copy link
Copy Markdown

This is the fix for Fixes #2148

Use an atomic create-if-absent operation for new lease creation during DISCOVER and REQUEST:

try to create the lease key only if it does not already exist
if creation fails because the key already exists, fetch and reuse the existing lease
never overwrite an existing lease with the short discover or negotiate TTL

Remarks: this fix was created with the help of AI. Please review it because i am not a GO expert

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 10, 2026

Deploy Preview for beryju-gravity canceled.

Name Link
🔨 Latest commit c076c14
🔍 Latest deploy log https://app.netlify.com/projects/beryju-gravity/deploys/69de9272ae6c400008ea37fa

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 10, 2026

Codecov Report

❌ Patch coverage is 82.71605% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.02%. Comparing base (9b663cc) to head (c076c14).
⚠️ Report is 32 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
pkg/roles/dhcp/leases.go 82.60% 6 Missing and 6 partials ⚠️
pkg/roles/dhcp/dhcp_handler4_request.go 71.42% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2149      +/-   ##
==========================================
+ Coverage   69.66%   70.02%   +0.35%     
==========================================
  Files         136      136              
  Lines        7441     7519      +78     
==========================================
+ Hits         5184     5265      +81     
+ Misses       1722     1719       -3     
  Partials      535      535              
Flag Coverage Δ
bench 12.72% <41.97%> (+0.37%) ⬆️
e2e 45.02% <44.44%> (-0.03%) ⬇️
unittest 56.80% <82.71%> (+0.44%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@BeryJu BeryJu changed the title DHCP: Fix concurrency issues on discover. roles/dhcp: Fix concurrency issues on discover. Apr 29, 2026
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.

DHCP: concurrent DISCOVER on multiple nodes can overwrite the same lease and downgrade it to negotiate TTL

1 participant