Page MenuHomePhabricator

[services] Tunnelbroker - Update Protobuf file with the `ping`
ClosedPublic

Authored by max on Sep 19 2022, 5:56 AM.
Tags
None
Referenced Files
F3525061: D5173.id16965.diff
Mon, Dec 23, 3:37 PM
F3524984: D5173.id16938.diff
Mon, Dec 23, 3:19 PM
F3524355: D5173.id16933.diff
Mon, Dec 23, 12:24 PM
Unknown Object (File)
Tue, Dec 3, 11:28 PM
Unknown Object (File)
Tue, Dec 3, 11:26 PM
Unknown Object (File)
Tue, Dec 3, 11:26 PM
Unknown Object (File)
Tue, Dec 3, 11:26 PM
Unknown Object (File)
Tue, Dec 3, 11:26 PM

Details

Summary

This diff introduces adding of ping in the GetResponse message for the Tunnelbroker API to check if the device is online.
This ping message will be sent to the client in a ping interval introduced in D5151. By pinging the client in a unidirectional Get stream we will be sure that the client is online and update the state of the client in the database using the method from D5165.
We can use the same approach when changing to the bidirectional stream in a near future in v.0.5.

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:40 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.

In D5173#151704, @max wrote:

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.

We currently have set(CMAKE_CXX_STANDARD 14) in the CMakeLists.txt file, however, this commit now includes C++17 extensions

This revision now requires changes to proceed.Sep 19 2022, 11:10 AM
shared/protos/tunnelbroker.proto
81 ↗(On Diff #16827)

feel like we should keep the naming more consistent

In D5173#151887, @jon wrote:
In D5173#151704, @max wrote:

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.

We currently have set(CMAKE_CXX_STANDARD 14) in the CMakeLists.txt file, however, this commit now includes C++17 extensions

The native error messages are related to some native client code that is expecting payload() in the GetResponse. So I should include the changes in this native client code as well according to the proto changes to make it build.

max added inline comments.
shared/protos/tunnelbroker.proto
81 ↗(On Diff #16827)

feel like we should keep the naming more consistent

Yeah, makes sense.

We currently have set(CMAKE_CXX_STANDARD 14) in the CMakeLists.txt file, however, this commit now includes C++17 extensions

Was seeing a lot of:

/workdir/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp:487:17: warning: decomposition declarations are a C++17 extension [-Wc++17-extensions]
     const auto &[applyMigration, shouldBeInTransaction] = migration;
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

warnings.

tomek requested changes to this revision.Sep 20 2022, 6:46 AM
tomek added inline comments.
shared/protos/tunnelbroker.proto
80 ↗(On Diff #16827)

What kind of date is this? Is it a typo?

max marked an inline comment as done.

Fixing native client build.

messageResponse changed to responseMessage to follow a convention. Fixing a typo.

max added inline comments.
shared/protos/tunnelbroker.proto
80 ↗(On Diff #16827)

What kind of date is this? Is it a typo?

Sorry, this is a typo. It was changed to the data.

81 ↗(On Diff #16827)

feel like we should keep the naming more consistent

I have changed the name to the responseMessage.

Change ping type from bool to google.protobuf.Empty.

tomek edited reviewers, added: ashoat; removed: tomek.

Not really sure about good practices here, but for me it sounds strange that we're using the same function for two completely different purposes. Shouldn't we introduce a new function which handles just the ping?

Adding @ashoat to get his perspective and because this is a protobuf diff.

native/cpp/CommonCpp/grpc/ClientGetReadReactor.cpp
19 ↗(On Diff #16938)

Is this name generated by gRPC?

In D5173#152584, @tomek wrote:

Not really sure about good practices here, but for me it sounds strange that we're using the same function for two completely different purposes. Shouldn't we introduce a new function which handles just the ping?

We already have a unidirectional stream and will switch to the bidirectional stream in the near future. In this case, we can use a single stream to send new messages and pings as well. If we create a new stream request we need to spawn a new additional thread with the request in the client and handle it. This will overcopmlicate the easy thing.

There is an keep-alive gRPC mechanism which maybe we consider to use in the near-term instead of pinging by ourselves. At the moment I've postponed investigating this and created a future task as it doesn't work as expected in the testing repo.

native/cpp/CommonCpp/grpc/ClientGetReadReactor.cpp
19 ↗(On Diff #16938)

Is this name generated by gRPC?

Yes, right!

We'll rethink this API in ENG-1072 and ENG-484. Would be good to prioritize ENG-1842 for Tunnelbroker v0.5 as well... I would like us to nail the API down in that version, so we can avoid having to change it while the service is live in the future.

We'll rethink this API in ENG-1072 and ENG-484. Would be good to prioritize ENG-1842 for Tunnelbroker v0.5 as well... I would like us to nail the API down in that version, so we can avoid having to change it while the service is live in the future.

Yes, that's why the current changes are made keeping that in mind to make the transition as easy and fast as possible and not time-consuming.

This revision is now accepted and ready to land.Sep 21 2022, 9:55 AM
This revision was landed with ongoing or failed builds.Sep 21 2022, 2:29 PM
This revision was automatically updated to reflect the committed changes.

Why did the builds fail?

Looks like a Nix configuration issue:

$ trap 'kill -- $$' INT TERM QUIT; cd services/tunnelbroker
rm -rf build && mkdir build && cd build
nix develop --command bash -c "cmake .. && make -j"
./bin/runTests --gtest_filter=-AmqpManager*:DatabaseManager*
path '/opt/homebrew/var/buildkite-agent/builds/mac-broadway-local-1/comm/tunnelbroker-unit-tests/services/tunnelbroker/build' does not contain a 'flake.nix', searching up
do you want to allow configuration setting 'extra-trusted-public-keys' to be set to 'comm.cachix.org-1:70RF31rkmCEhQ9HrXA2uXcpqQKGcUK3TxLJdgcUCaA4=' (y/N)? # Received cancellation signal, interrupting
error: interrupted by the user
🚨 Error: The command exited with status 1
user command error: exit status 1

Probably @max didn't rebase on master after @jon's recent changes. We should make sure the recent changes solve the issue, or otherwise create a task and/or diff to resolve

Probably @max didn't rebase on master after @jon's recent changes.

Yes, that's the problem here.

We should make sure the recent changes solve the issue, or otherwise create a task and/or diff to resolve

Seems that it's solved because the recently rebased diffs are successful. For example: D5081, D5145