Skip to content

DHCP: Fix concurrency issues on discover. #2149

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

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 64.19753% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.62%. Comparing base (9b663cc) to head (2705ab1).
⚠️ Report is 11 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
pkg/roles/dhcp/leases.go 68.11% 12 Missing and 10 partials ⚠️
pkg/roles/dhcp/dhcp_handler4_request.go 28.57% 3 Missing and 2 partials ⚠️
pkg/roles/dhcp/dhcp_handler4_discover.go 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2149      +/-   ##
==========================================
- Coverage   69.66%   69.62%   -0.05%     
==========================================
  Files         136      136              
  Lines        7441     7519      +78     
==========================================
+ Hits         5184     5235      +51     
- Misses       1722     1737      +15     
- Partials      535      547      +12     
Flag Coverage Δ
bench 12.67% <41.97%> (+0.32%) ⬆️
e2e 45.02% <44.44%> (-0.03%) ⬇️
unittest 56.45% <64.19%> (+0.09%) ⬆️

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.

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