Page MenuHomePhabricator

[Tunnelbroker] always persist gRPC messages in database
ClosedPublic

Authored by kamil on Sep 28 2023, 7:35 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 10, 3:29 PM
Unknown Object (File)
Fri, Nov 1, 11:08 AM
Unknown Object (File)
Fri, Nov 1, 11:08 AM
Unknown Object (File)
Fri, Nov 1, 11:06 AM
Unknown Object (File)
Fri, Nov 1, 10:46 AM
Unknown Object (File)
Fri, Nov 1, 6:41 AM
Unknown Object (File)
Oct 2 2024, 9:03 AM
Unknown Object (File)
Oct 2 2024, 9:03 AM
Subscribers

Details

Summary
  • We need to make sure that each message is delivered to client.
  • We need to persist it immediately after receiving
  • Message will be removed after confirmation from client

Depends on D9312

Test Plan
  1. Restart RabbitMQ
  2. Restart localstack
  3. Run this code:
#[tokio::test]
async fn send_grpc() {
  let refresh_request = RefreshKeyRequest {
    device_id: "test_persist".to_string(),
    number_of_keys: 5,
  };

  let request = MessageToDevice {
    device_id: "test_persist".to_string(),
    payload: serde_json::to_string(&refresh_request).unwrap(),
  };
  let grpc_message = tonic::Request::new(request);

  TunnelbrokerServiceClient::connect("http://localhost:50051")
    .await
    .unwrap()
    .send_message_to_device(grpc_message)
    .await
    .unwrap();
}
  1. Open RabbitMQ management console, there should be one dropped message (there is no device with test_persist ID)

Screenshot 2023-09-27 at 15.48.09.png (224×641 px, 28 KB)

  1. Open DynamoDB console, message should be persisted:

Screenshot 2023-09-27 at 15.48.25.png (513×1 px, 64 KB)

  1. Additionally, check TB logs for:
2023-09-27T13:47:23.107877Z DEBUG tunnelbroker::grpc: Received message for test_persist
2023-09-27T13:47:23.107920Z DEBUG tunnelbroker::database: Persisting message to device: test_persist

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kamil held this revision as a draft.
kamil published this revision for review.Sep 28 2023, 8:09 AM

Did you think of expected behavior in case of failure?
Current code aborts publishing a message to RabbitMQ if DDB persistence fails. Is that expected?

Did you think of expected behavior in case of failure?

Yes, created ENG-5149 to discuss this, initially I wanted to implement option 2, but probably we can discuss it.

Current code aborts publishing a message to RabbitMQ if DDB persistence fails. Is that expected?

Yes, this diff intention to make it mandatory to put messages in DDB. Failures are separate thing, handling will be tracked in ENG-5149.

This revision is now accepted and ready to land.Sep 29 2023, 8:32 AM