Skip to content

Commit cf56c69

Browse files
authored
fix: try to vacuum non-default branches (#4911)
Whatever token we are getting does not have access to non-default branches and generates a GitHub 403. Using the other token method seems to work.
1 parent ce7b057 commit cf56c69

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

app_dart/lib/src/request_handlers/scheduler/batch_backfiller.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ final class BatchBackfiller extends RequestHandler {
127127
(commit, [...tasks.map((t) => t.toRef())]),
128128
], postsubmitTargets: currentTargets);
129129
}
130-
log.debug('Built a grid of ${grid.eligibleTasks.length} target columns');
130+
log.debug(
131+
'Built a grid of ${grid.eligibleTasks.length} target columns for $grid',
132+
);
131133

132134
// Produce a list of tasks, ordered from highest to lowest, to backfill.
133135
// ... but only take the top N tasks, at most.

app_dart/lib/src/request_handlers/vacuum_github_commits.dart

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,28 @@ final class VacuumGithubCommits extends ApiRequestHandler {
8383
'Listing commit for slug: $slug branch: $branch and msSinceEpoch: '
8484
'${queryAfter.millisecondsSinceEpoch}',
8585
);
86-
commits = await githubService.listBranchedCommits(
87-
slug,
88-
branch,
89-
queryAfter.millisecondsSinceEpoch,
90-
);
86+
87+
try {
88+
commits = await githubService.listBranchedCommits(
89+
slug,
90+
branch,
91+
queryAfter.millisecondsSinceEpoch,
92+
);
93+
} catch (e) {
94+
log.error('Failed retrieving commits from githubService', e);
95+
96+
final gh = config.createGitHubClientWithToken(
97+
await config.githubOAuthToken,
98+
);
99+
commits = await gh.repositories
100+
.listCommits(
101+
slug,
102+
sha: branch,
103+
since: queryAfter,
104+
until: queryBefore,
105+
)
106+
.toList();
107+
}
91108
log.debug('Retrieved ${commits.length} commits from GitHub');
92109
// Do not try to add recent commits as they may already be processed
93110
// by cocoon, which can cause race conditions.
@@ -99,7 +116,7 @@ final class VacuumGithubCommits extends ApiRequestHandler {
99116
)
100117
.toList();
101118
} on gh.GitHubError catch (e) {
102-
log.error('Failed retriving commits from GitHub', e);
119+
log.error('Failed retrieving commits from GitHub', e);
103120
}
104121

105122
return [

0 commit comments

Comments
 (0)