Skip to content

Commit

Permalink
Merge pull request github#10378 from github/repo-sync
Browse files Browse the repository at this point in the history
repo sync
  • Loading branch information
Octomerger authored Sep 28, 2021
2 parents 5718cfe + 349b72c commit b41dca1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
15 changes: 10 additions & 5 deletions script/deployment/deploy-to-production.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ const SLEEP_INTERVAL = 5000
const HEROKU_LOG_LINES_TO_SHOW = 25
const DELAY_FOR_PREBOOT_SWAP = 135000 // 2:15

// Allow for a few 404 (Not Found) or 429 (Too Many Requests) responses from the
// semi-unreliable Heroku API when we're polling for status updates
// Allow for a few 404 (Not Found), 429 (Too Many Requests), etc. responses from
// the semi-unreliable Heroku API when we're polling for status updates
const ALLOWED_MISSING_RESPONSE_COUNT = 5
const ALLOWABLE_ERROR_CODES = [404, 429, 500]

export default async function deployToProduction({
octokit,
Expand Down Expand Up @@ -179,7 +180,7 @@ export default async function deployToProduction({
build = await heroku.get(`/apps/${appName}/builds/${buildId}`)
} catch (error) {
// Allow for a few bad responses from the Heroku API
if (error.statusCode === 404 || error.statusCode === 429) {
if (isAllowableHerokuError(error)) {
buildAcceptableErrorCount += 1
if (buildAcceptableErrorCount <= ALLOWED_MISSING_RESPONSE_COUNT) {
continue
Expand Down Expand Up @@ -232,7 +233,7 @@ export default async function deployToProduction({
release = result
} catch (error) {
// Allow for a few bad responses from the Heroku API
if (error.statusCode === 404 || error.statusCode === 429) {
if (isAllowableHerokuError(error)) {
releaseAcceptableErrorCount += 1
if (releaseAcceptableErrorCount <= ALLOWED_MISSING_RESPONSE_COUNT) {
continue
Expand Down Expand Up @@ -291,7 +292,7 @@ export default async function deployToProduction({
)
} catch (error) {
// Allow for a few bad responses from the Heroku API
if (error.statusCode === 404 || error.statusCode === 429) {
if (isAllowableHerokuError(error)) {
dynoAcceptableErrorCount += 1
if (dynoAcceptableErrorCount <= ALLOWED_MISSING_RESPONSE_COUNT) {
continue
Expand Down Expand Up @@ -440,6 +441,10 @@ async function getTarballUrl({ octokit, owner, repo, sha }) {
return tarballUrl
}

function isAllowableHerokuError(error) {
return error && ALLOWABLE_ERROR_CODES.includes(error.statusCode)
}

function announceIfHerokuIsDown(error) {
if (error && error.statusCode === 503) {
console.error('💀 Heroku may be down! Please check its Status page: https://status.heroku.com/')
Expand Down
17 changes: 11 additions & 6 deletions script/deployment/deploy-to-staging.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import createStagingAppName from './create-staging-app-name.js'
const SLEEP_INTERVAL = 5000
const HEROKU_LOG_LINES_TO_SHOW = 25

// Allow for a few 404 (Not Found) or 429 (Too Many Requests) responses from the
// semi-unreliable Heroku API when we're polling for status updates
// Allow for a few 404 (Not Found), 429 (Too Many Requests), etc. responses from
// the semi-unreliable Heroku API when we're polling for status updates
const ALLOWED_MISSING_RESPONSE_COUNT = 5
const ALLOWABLE_ERROR_CODES = [404, 429, 500]

export default async function deployToStaging({
octokit,
Expand Down Expand Up @@ -238,7 +239,7 @@ export default async function deployToStaging({
build = appSetup.build
} catch (error) {
// Allow for a few bad responses from the Heroku API
if (error.statusCode === 404 || error.statusCode === 429) {
if (isAllowableHerokuError(error)) {
setupAcceptableErrorCount += 1
if (setupAcceptableErrorCount <= ALLOWED_MISSING_RESPONSE_COUNT) {
continue
Expand Down Expand Up @@ -321,7 +322,7 @@ See Heroku logs for more information:\n${logUrl}`
build = await heroku.get(`/apps/${appName}/builds/${buildId}`)
} catch (error) {
// Allow for a few bad responses from the Heroku API
if (error.statusCode === 404 || error.statusCode === 429) {
if (isAllowableHerokuError(error)) {
buildAcceptableErrorCount += 1
if (buildAcceptableErrorCount <= ALLOWED_MISSING_RESPONSE_COUNT) {
continue
Expand Down Expand Up @@ -374,7 +375,7 @@ See Heroku logs for more information:\n${logUrl}`
release = result
} catch (error) {
// Allow for a few bad responses from the Heroku API
if (error.statusCode === 404 || error.statusCode === 429) {
if (isAllowableHerokuError(error)) {
releaseAcceptableErrorCount += 1
if (releaseAcceptableErrorCount <= ALLOWED_MISSING_RESPONSE_COUNT) {
continue
Expand Down Expand Up @@ -480,7 +481,7 @@ See Heroku logs for more information:\n${logUrl}`
)
} catch (error) {
// Allow for a few bad responses from the Heroku API
if (error.statusCode === 404 || error.statusCode === 429) {
if (isAllowableHerokuError(error)) {
dynoAcceptableErrorCount += 1
if (dynoAcceptableErrorCount <= ALLOWED_MISSING_RESPONSE_COUNT) {
continue
Expand Down Expand Up @@ -646,6 +647,10 @@ async function getTarballUrl({ octokit, owner, repo, sha }) {
return tarballUrl
}

function isAllowableHerokuError(error) {
return error && ALLOWABLE_ERROR_CODES.includes(error.statusCode)
}

function announceIfHerokuIsDown(error) {
if (error && error.statusCode === 503) {
console.error('💀 Heroku may be down! Please check its Status page: https://status.heroku.com/')
Expand Down

0 comments on commit b41dca1

Please sign in to comment.