netbird icon indicating copy to clipboard operation
netbird copied to clipboard

Debounce network changes

Open hurricanehrndz opened this issue 1 year ago • 3 comments

Describe your changes

Block restarting netbird engine for 3s when network change detected. This will help prevent Netbird from attempting to create multiple wiregurad interfaces when restarting the engine in rapid succession

Issue ticket number and link

#2196 #2130

Checklist

  • [x] Is it a bug fix
  • [ ] Is a typo/documentation fix
  • [ ] Is a feature enhancement
  • [ ] It is a refactor
  • [ ] Created tests that fail without the change (if possible)
  • [ ] Extended the README / documentation, if necessary

hurricanehrndz avatar Jun 25 '24 18:06 hurricanehrndz

Please feel free to make changes as you fit

hurricanehrndz avatar Jun 25 '24 18:06 hurricanehrndz

@hurricanehrndz Thank you for the PR! I have a question. You made a new, custom struct for locking the time value. In your change, you are doing multiple operations under the locked state. I am not sure if that is necessary or not. If not then it could be better to use an atomic store. The atomic provides options to store value in atomic way. https://pkg.go.dev/sync/atomic

pappz avatar Jun 28 '24 10:06 pappz

@hurricanehrndz Thank you for the PR! I have a question. You made a new, custom struct for locking the time value. In your change, you are doing multiple operations under the locked state. I am not sure if that is necessary or not. If not then it could be better to use an atomic store. The atomic provides options to store value in atomic way. https://pkg.go.dev/sync/atomic

I think it is necessary because the bug is caused by a race condition. When a device has multiple network interfaces all with a default route to the internet, the callback function will be called multiple times simultaneously.

hurricanehrndz avatar Jun 28 '24 13:06 hurricanehrndz

Hi @hurricanehrndz,

we want to go with a slightly different solution that doesn't ignore potential changes for 3 seconds. I'll close this PR and create a new one. Thank you for bringing the issue to our attention and the inspiration.

lixmal avatar Jul 01 '24 13:07 lixmal

Please tag me on the new PR and I can test it for you.

Get Outlook for iOShttps://aka.ms/o0ukef


From: Viktor Liu @.> Sent: Monday, July 1, 2024 7:57:00 AM To: netbirdio/netbird @.> Cc: Carlos Hernandez @.>; Mention @.> Subject: Re: [netbirdio/netbird] Debounce network changes (PR #2197)

Hi @hurricanehrndzhttps://github.com/hurricanehrndz,

we want to go with a slightly different solution that doesn't ignore potential changes for 3 seconds. I'll close this PR and create a new one. Thank you for bringing the issue to our attention and the inspiration.

— Reply to this email directly, view it on GitHubhttps://github.com/netbirdio/netbird/pull/2197#issuecomment-2200228310, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABMJBTKWN7FQFSAUONYUF2TZKFN2ZAVCNFSM6AAAAABJ4LT4FKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBQGIZDQMZRGA. You are receiving this because you were mentioned.Message ID: @.***>

hurricanehrndz avatar Jul 01 '24 13:07 hurricanehrndz