Page MenuHomePhabricator

[keyserver] cron job to refresh account prekeys
ClosedPublic

Authored by kamil on Oct 9 2023, 7:03 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 20, 12:50 PM
Unknown Object (File)
Mon, Dec 16, 10:27 AM
Unknown Object (File)
Mon, Dec 16, 10:27 AM
Unknown Object (File)
Mon, Dec 16, 10:27 AM
Unknown Object (File)
Mon, Dec 16, 10:27 AM
Unknown Object (File)
Sat, Dec 14, 9:01 PM
Unknown Object (File)
Fri, Nov 29, 8:38 PM
Unknown Object (File)
Nov 14 2024, 9:18 PM
Subscribers

Details

Summary

Issue: ENG-3944.

This is part of D8476 (breaking this for smaller diffs because it's complex).

Diff which publishes keys to Identity service.

Depends on D9420

Test Plan
  1. Call revalidateAccountPrekeys() to make sure checks work properly
  2. Call publishNewPrekeys() to make sure upload works properly.
  3. Check Identity logs for Refreshing prekeys for user: ...
  4. Check if time (last_prekey_publish_time) is updated after successful upload.

Test error:

  1. Delete user credentials (identity will fail to auth while refreshing keys)
  2. Trigger cron job
  3. check logs for encountered error while trying to validate prekeys

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kamil held this revision as a draft.

Looks fine assuming that we always want to rotate both even if only one actually needs rotation. Make sure you get @varun acceptance before landing since I don't have enough context to review publishNewPrekeys

This revision is now accepted and ready to land.Oct 10 2023, 3:33 AM
This revision now requires review to proceed.Oct 10 2023, 3:50 AM
ashoat added inline comments.
keyserver/src/utils/olm-utils.js
204 ↗(On Diff #31799)

We can take this console.log out

varun requested changes to this revision.Oct 10 2023, 8:21 PM

Refreshing prekeys for user: ... just means the Identity service received the RefreshUserPreKeys request. Shouldn't we make sure that we actually received a successful response from the Identity service?

Also what happens if, say, the Identity service is offline? Does publishNewPrekeys fail gracefully? Maybe it doesn't matter since we only call it from a cron job?

This revision now requires changes to proceed.Oct 10 2023, 8:21 PM
kamil requested review of this revision.Oct 11 2023, 3:30 AM
In D9421#277121, @varun wrote:

Refreshing prekeys for user: ... just means the Identity service received the RefreshUserPreKeys request. Shouldn't we make sure that we actually received a successful response from the Identity service?

We do. We throw an error when refresh_user_pre_keys call fails.
Checking refresh_user_pre_keys response doesn't make sense because it returns an empty response.
Checking rustAPI.publishPrekeys() response also doesn't make sense, because it always returns true. (Probably this is some convention in Rust codebase? Was introduced in D8473)

So basically we await rustAPI.publishPrekeys() and this means success or it throws an error.

Also what happens if, say, the Identity service is offline? Does publishNewPrekeys fail gracefully? Maybe it doesn't matter since we only call it from a cron job?

When identity is offline, or anything went wrong on identity, the cron job fails silently (see it's surrounded via try {} catch() {}. I think we can keep publishNewPrekeys to throw error and make caller's responsibility to handle this.

Checking rustAPI.publishPrekeys() response also doesn't make sense, because it always returns true. (Probably this is some convention in Rust codebase? Was introduced in D8473)

yeah not sure why we need a bool here at all, actually... could just be Result<()> instead

This revision is now accepted and ready to land.Oct 11 2023, 7:06 AM
kamil edited the test plan for this revision. (Show Details)

revalidateAccountPrekeys -> validateAndUploadAccountPrekeys