Skip to content

Commit

Permalink
fix(sl): add retries when creating indirection domain (#935)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcshzj authored Sep 6, 2023
1 parent 9ba39d2 commit ae722b9
Show file tree
Hide file tree
Showing 3 changed files with 234 additions and 35 deletions.
258 changes: 225 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@aws-sdk/client-secrets-manager": "^3.370.0",
"@aws-sdk/lib-dynamodb": "^3.370.0",
"@growthbook/growthbook": "^0.27.0",
"@octokit/plugin-retry": "^6.0.0",
"@octokit/rest": "^18.12.0",
"@opengovsg/formsg-sdk": "^0.10.0",
"@opengovsg/sgid-client": "^2.0.0",
Expand Down
10 changes: 8 additions & 2 deletions src/services/identity/ReposService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from "fs"

import { retry } from "@octokit/plugin-retry"
import { Octokit } from "@octokit/rest"
// eslint-disable-next-line import/no-extraneous-dependencies
import { GetResponseTypeFromEndpointMethod } from "@octokit/types"
Expand All @@ -19,6 +20,11 @@ import logger from "@root/logger/logger"

const SYSTEM_GITHUB_TOKEN = config.get("github.systemToken")
const octokit = new Octokit({ auth: SYSTEM_GITHUB_TOKEN })
const OctokitRetry = Octokit.plugin(retry as any)
const octokitWithRetry = new OctokitRetry({
auth: SYSTEM_GITHUB_TOKEN,
request: { retries: 5 },
})

// Constants
const SITE_CREATION_BASE_REPO_URL =
Expand Down Expand Up @@ -332,7 +338,7 @@ export const createRecords = (zoneId: string): Record[] => {
})
.andThen((sha) =>
ResultAsync.fromPromise(
octokit.repos.createOrUpdateFileContents({
octokitWithRetry.repos.createOrUpdateFileContents({
owner: ISOMER_GITHUB_ORGANIZATION_NAME,
repo: DNS_INDIRECTION_REPO,
path: `dns/${primaryDomain}.ts`,
Expand All @@ -355,7 +361,7 @@ export const createRecords = (zoneId: string): Record[] => {
}

return ResultAsync.fromPromise(
octokit.repos.createOrUpdateFileContents({
octokitWithRetry.repos.createOrUpdateFileContents({
owner: ISOMER_GITHUB_ORGANIZATION_NAME,
repo: DNS_INDIRECTION_REPO,
path: `dns/${primaryDomain}.ts`,
Expand Down

0 comments on commit ae722b9

Please sign in to comment.