Page MenuHomePhabricator

[services] Tunnelbroker - Update device online status in `Get` handler
ClosedPublic

Authored by max on Sep 19 2022, 5:57 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 27, 9:38 AM
Unknown Object (File)
Fri, Apr 26, 7:14 PM
Unknown Object (File)
Mar 28 2024, 1:04 PM
Unknown Object (File)
Mar 2 2024, 1:08 PM
Unknown Object (File)
Mar 2 2024, 5:40 AM
Unknown Object (File)
Mar 2 2024, 5:40 AM
Unknown Object (File)
Mar 2 2024, 5:40 AM
Unknown Object (File)
Mar 2 2024, 5:40 AM

Details

Summary

This diff introduces an update of the device's online state in the database when the ping message or the payload message write was unsuccessful.

This is a part of the stack.

Related Linear task: ENG-1766

Test Plan

Successfully built the server and the follow-up diffs in the stack.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

max held this revision as a draft.
max edited the test plan for this revision. (Show Details)
max added a reviewer: tomek.
max published this revision for review.Sep 19 2022, 6:39 AM

I'm checking what's wrong with the Android and iOS builds (maybe the protobuf changes broke some old client-side API code). Requesting review to unblock it for possible comments.

would be nice to have a test case that the online behavior is being correctly updated.

tomek requested changes to this revision.Sep 20 2022, 6:59 AM

This is rather strange: for each get request we have an infinite loop of ping - is this the right approach?

services/tunnelbroker/src/Service/TunnelbrokerServiceImpl.cpp
265–269 ↗(On Diff #16829)

In case of an error, maybe we should also set the status to offline?

This revision now requires changes to proceed.Sep 20 2022, 6:59 AM

Rebasing on the parent changes.

max added inline comments.
services/tunnelbroker/src/Service/TunnelbrokerServiceImpl.cpp
265–269 ↗(On Diff #16829)

In case of an error, maybe we should also set the status to offline?

In the latest update we are switching the device as Online in the handler after we did a session checks.
We are switching it as Offline in:

  • When the write failed and we are switching the std::atomic_bool writerIsReady to false;
  • When the exception occurred;
  • When the unexpected error occured.
In D5175#152307, @tomek wrote:

This is rather strange: for each get request we have an infinite loop of ping - is this the right approach?

Yes, we are sending pings to make sure the device is Online, in case the write failed we are exiting from the loop and thread and considering the device as Offline.

In D5175#151890, @jon wrote:

would be nice to have a test case that the online behavior is being correctly updated.

Speaking of the unit tests we already have tests in D5166. To test how this algorithm behaves it can be tested by the isolated test using my repo on which I've tested this approach.
I don't think we can do such automated integration tests now (connect client, drop the connection, check the database status). So it can be checked manually, but would be cool to have it.

I'm still not sure if having this logic in get is the right approach. Added a comment about it in D5174 but accepting this diff because it looks ok

This revision is now accepted and ready to land.Sep 23 2022, 4:41 AM

Resolving merge conflicts.

In D5175#153316, @tomek wrote:

I'm still not sure if having this logic in get is the right approach. Added a comment about it in D5174 but accepting this diff because it looks ok

After the logic explanation in D5174 Tomek accepted the D5174, so I'm landing this one too.

This revision was landed with ongoing or failed builds.Sep 23 2022, 2:07 PM
This revision was automatically updated to reflect the committed changes.