Open ctrl-zzz opened 5 months ago
Hello,
I've been looking for the issue and I noticed that the connected
field is also set to true
in the db, even after a disconnection. There's not a problem while retrieving the value, it just never gets updated after a netbird down
.
The problem should be in how the field gets updated in the SavePeerStatus function in the management/server/sql_store.go
file, particularly because of how GORM manages the update itself. There's an explanation on the GORM documentation on why this happens; updating the SavePeerStatus
function accordingly solved the problem for me. Now the status
field gets updated correctly and its value in the db stays consistent.
This could be an issue for other updates as well, so I wanted to give you a heads up about it.
Describe the problem
I've been trying to implement a session-expire feature that checks the
connected
status of a peer; when a peer gets disconnected its login is marked as expired. The problem is that afternetbird down
theconnected
status seems to be stuck attrue
, so the session can never expire.I've made sure my code doesn't interfere with the expected behavior and double checked without applying my changes that the problem persists.
To Reproduce
Steps to reproduce the behavior:
management/server/account.go
file print thepeer.Status.Connected
value immediately after the MarkPeerConnected callnetbird up
andnetbird down
connected
fieldExpected behavior
The
connected
field should be set to false.Are you using NetBird Cloud?
No, I'm selfhosting it.
Additional context
When GETting a peer using the NetBird REST API its
connected
field behaves normally, being set atfalse
afternetbird down
.