Skip to content

Commit

Permalink
[identity] Optimize Tunnelbroker device data removal
Browse files Browse the repository at this point in the history
Summary:
Noticed that we're spawning Tunnelbroker task in a loop with single device.
Instead, all devices array can be passed once

Depends on D14173

Test Plan: Commtest, removing a device using UI

Reviewers: kamil

Reviewed By: kamil

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D14174
  • Loading branch information
barthap committed Dec 20, 2024
1 parent 6fd253e commit c44920a
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions services/identity/src/database/device_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1590,26 +1590,26 @@ impl DatabaseClient {
"{} devices have been removed from device list. Clearing data...",
devices_being_removed.len()
);
for device_id in devices_being_removed {
for device_id in &devices_being_removed {
trace!("Invalidating CSAT for device {}", device_id);
self.delete_access_token_data(user_id, &device_id).await?;
self.delete_access_token_data(user_id, device_id).await?;
trace!("Clearing keys for device {}", device_id);
self.remove_device_data(user_id, &device_id).await?;
self.remove_device_data(user_id, device_id).await?;
trace!("Pruning OTKs for device {}", device_id);
self
.delete_otks_table_rows_for_user_device(user_id, &device_id)
.delete_otks_table_rows_for_user_device(user_id, device_id)
.await?;

let device_id = device_id.to_string();
tokio::spawn(async move {
debug!(
"Attempting to delete Tunnelbroker data for device: {}",
&device_id
);
let result = tunnelbroker::delete_devices_data(&[device_id]).await;
consume_error(result);
});
}

tokio::spawn(async move {
debug!(
"Attempting to delete Tunnelbroker data for {} devices",
devices_being_removed.len()
);
let result =
tunnelbroker::delete_devices_data(&devices_being_removed).await;
consume_error(result);
});
Ok(())
}

Expand Down

0 comments on commit c44920a

Please sign in to comment.