Skip to content

Commit

Permalink
Add logs to help triage Firestore task update failure (flutter#3489)
Browse files Browse the repository at this point in the history
  • Loading branch information
keyonghan authored Feb 14, 2024
1 parent 68c0d71 commit a89ba8d
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class PostsubmitLuciSubscription extends SubscriptionHandler {
task.updateFromBuild(build);
await datastore.insert(<Task>[task]);
try {
await updateFirestore(build, commitKey.id!, task.name!);
await updateFirestore(build, rawCommitKey, task.name!);
} catch (error) {
log.warning('Failed to update task in Firestore: $error');
}
Expand Down Expand Up @@ -144,12 +144,16 @@ class PostsubmitLuciSubscription extends SubscriptionHandler {
}

/// Queries the task document and updates based on the latest build data.
Future<void> updateFirestore(Build build, String sha, String taskName) async {
Future<void> updateFirestore(Build build, String commitKeyId, String taskName) async {
final FirestoreService firestoreService = await config.createFirestoreService();
final String sha = commitKeyId.split('/').last;
final String documentName = '$kDatabase/documents/tasks/${sha}_${taskName}_1';
log.info('getting firestore document: $documentName');
final f.Task firestoreTask =
await f.Task.fromFirestore(firestoreService: firestoreService, documentName: documentName);
log.info('updating firestoreTask based on build');
firestoreTask.updateFromBuild(build);
log.info('finished updating firestoreTask based on builds');
final List<Write> writes = documentsToWrites([firestoreTask], exists: true);
await firestoreService.batchWriteDocuments(BatchWriteRequest(writes: writes), kDatabase);
}
Expand Down

0 comments on commit a89ba8d

Please sign in to comment.