Skip to content

Commit cf84d83

Browse files
Adding a log for builders found vs build name in presubmit subscription (flutter#3111)
Occasionally we hit an issue where we cannot get an element from the ciYaml and then cannot update an existing task in presubmit. This implies that we found none or more than one task. This log message will let us know which it is if hit again. *List which issues are fixed by this PR. You must list at least one issue.* Related to flutter/flutter#135640 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
1 parent 5050eb6 commit cf84d83

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

app_dart/lib/src/request_handlers/presubmit_luci_subscription.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ class PresubmitLuciSubscription extends SubscriptionHandler {
119119
} else {
120120
ciYaml = await scheduler.getCiYaml(commit);
121121
}
122+
123+
// Do not block on the target not found.
124+
if (!ciYaml.presubmitTargets.any((element) => element.value.name == builderName)) {
125+
// do not reschedule
126+
log.warning('Did not find builder with name: $builderName in ciYaml for ${commit.sha}');
127+
final List<String> availableBuilderList = ciYaml.presubmitTargets.map((Target e) => e.value.name).toList();
128+
log.warning('ciYaml presubmit targets found: $availableBuilderList');
129+
return 1;
130+
}
131+
122132
final Target target = ciYaml.presubmitTargets.where((element) => element.value.name == builderName).single;
123133
final Map<String, Object> properties = target.getProperties();
124134
if (!properties.containsKey('presubmit_max_attempts')) {

app_dart/test/request_handlers/presubmit_luci_subscription_test.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,29 @@ void main() {
158158
);
159159
verify(mockGithubChecksService.updateCheckStatus(any, any, any, rescheduled: true)).called(1);
160160
});
161+
162+
test('Build not rescheduled if not found in ciYaml list.', () async {
163+
when(mockGithubChecksService.updateCheckStatus(any, any, any, rescheduled: false)).thenAnswer((_) async => true);
164+
when(mockGithubChecksService.taskFailed(any)).thenAnswer((_) => true);
165+
when(mockGithubChecksService.currentAttempt(any)).thenAnswer((_) => 1);
166+
tester.message = createBuildbucketPushMessage(
167+
'COMPLETED',
168+
result: 'SUCCESS',
169+
// This builder will not be present.
170+
builderName: 'Linux C',
171+
userData: '{\\"repo_owner\\": \\"flutter\\",'
172+
'\\"commit_branch\\": \\"main\\",'
173+
'\\"commit_sha\\": \\"abc\\",'
174+
'\\"repo_name\\": \\"flutter\\"}',
175+
);
176+
await tester.post(handler);
177+
verifyNever(
178+
mockLuciBuildService.rescheduleBuild(
179+
builderName: 'Linux C',
180+
buildPushMessage: BuildPushMessage.fromPushMessage(tester.message),
181+
rescheduleAttempt: 1,
182+
),
183+
);
184+
verify(mockGithubChecksService.updateCheckStatus(any, any, any, rescheduled: false)).called(1);
185+
});
161186
}

0 commit comments

Comments
 (0)