Skip to content

Commit b3268c2

Browse files
authored
Do not try to rerun experimental branch task failures. (#4677)
Towards flutter/flutter#168738. This keeps task utilization of `ios-experimental` lower. More work is required to make this work e2e. /cc @vashworth
1 parent 932c17b commit b3268c2

2 files changed

Lines changed: 74 additions & 0 deletions

File tree

app_dart/lib/src/request_handlers/postsubmit_luci_subscription.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'dart:convert';
66
import 'dart:io';
77

88
import 'package:buildbucket/buildbucket_pb.dart' as bbv2;
9+
import 'package:cocoon_common/is_release_branch.dart';
910
import 'package:cocoon_server/logging.dart';
1011
import 'package:googleapis/firestore/v1.dart' hide Status;
1112

@@ -15,6 +16,7 @@ import '../model/firestore/task.dart' as fs;
1516
import '../request_handling/request_handler.dart';
1617
import '../request_handling/response.dart';
1718
import '../request_handling/subscription_handler.dart';
19+
import '../service/config.dart';
1820
import '../service/firestore.dart';
1921
import '../service/github_checks_service.dart';
2022
import '../service/luci_build_service.dart';
@@ -185,6 +187,14 @@ final class PostsubmitLuciSubscription extends SubscriptionHandler {
185187
_firestore,
186188
sha: task.commitSha,
187189
);
190+
if (currentCommit.branch != Config.defaultBranch(currentCommit.slug) &&
191+
!isReleaseCandidateBranch(branchName: currentCommit.branch)) {
192+
log.info(
193+
'Skip automatic reruns for experimental branch ${currentCommit.branch}',
194+
);
195+
return false;
196+
}
197+
188198
final commitList = await _firestore.queryRecentCommits(
189199
limit: 1,
190200
slug: currentCommit.slug,

app_dart/test/request_handlers/postsubmit_luci_subscription_test.dart

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import 'package:buildbucket/buildbucket_pb.dart' as bbv2;
66
import 'package:cocoon_common/task_status.dart';
7+
import 'package:cocoon_common_test/cocoon_common_test.dart';
8+
import 'package:cocoon_server/logging.dart';
79
import 'package:cocoon_server_test/test_logging.dart';
810
import 'package:cocoon_service/cocoon_service.dart';
911
import 'package:cocoon_service/src/model/firestore/task.dart' as fs;
@@ -611,6 +613,13 @@ void main() {
611613
await tester.post(handler);
612614

613615
expect(firestore, existsInStorage(fs.Task.metadata, hasLength(1)));
616+
617+
expect(
618+
log,
619+
bufferedLoggerOf(
620+
contains(logThat(message: contains('Max retries reached'))),
621+
),
622+
);
614623
});
615624

616625
test('skips rerunning when builder is not in tip-of-tree', () async {
@@ -647,5 +656,60 @@ void main() {
647656
await tester.post(handler);
648657

649658
expect(firestore, existsInStorage(fs.Task.metadata, hasLength(1)));
659+
660+
expect(
661+
log,
662+
bufferedLoggerOf(contains(logThat(message: contains('Not tip of tree')))),
663+
);
664+
});
665+
666+
// Regression test for https://github.com/flutter/flutter/issues/168738.
667+
test('skips rerunning when builder is an experimental branch', () async {
668+
final fsCommit = generateFirestoreCommit(
669+
1,
670+
sha: '87f88734747805589f2131753620d61b22922822',
671+
// Notably not "master" or "flutter-X.XX-candidate.0".
672+
branch: 'ios-experimental',
673+
);
674+
final fsTask = generateFirestoreTask(
675+
1,
676+
name: 'Linux A',
677+
commitSha: fsCommit.sha,
678+
status: TaskStatus.inProgress,
679+
);
680+
firestore.putDocument(fsCommit);
681+
firestore.putDocument(fsTask);
682+
683+
// Add another commit to ToT.
684+
firestore.putDocument(generateFirestoreCommit(2));
685+
686+
tester.message = createPushMessage(
687+
Int64(1),
688+
status: bbv2.Status.FAILURE,
689+
builder: 'Linux A',
690+
userData: PostsubmitUserData(
691+
checkRunId: null,
692+
taskId: fs.TaskId(
693+
commitSha: fsCommit.sha,
694+
taskName: fsTask.taskName,
695+
currentAttempt: fsTask.currentAttempt,
696+
),
697+
),
698+
);
699+
700+
await tester.post(handler);
701+
702+
expect(firestore, existsInStorage(fs.Task.metadata, hasLength(1)));
703+
704+
expect(
705+
log,
706+
bufferedLoggerOf(
707+
contains(
708+
logThat(
709+
message: contains('Skip automatic reruns for experimental branch'),
710+
),
711+
),
712+
),
713+
);
650714
});
651715
}

0 commit comments

Comments
 (0)