Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sl): add retries when creating indirection domain #935

Merged
merged 1 commit into from
Sep 6, 2023

Conversation

dcshzj
Copy link
Contributor

@dcshzj dcshzj commented Sep 5, 2023

Problem

Creating the DNS indirection domain will fail when multiple site launches are performed in a single site launch form submission.

Solution

Breaking Changes

  • Yes - this PR contains breaking changes
  • No - this PR is backwards compatible

Bug Fixes:

  • An octokit plugin (@octokit/plugin-retry) is used to automatically retry on retry-able errors. This includes the 409 error code returned by GitHub due to concurrent edits made to the indirection repository.

Tests

Unable to test directly as this is a site launch change. However, the following code was used to simulate concurrent creation of files:

const { Octokit } = require("@octokit/rest");
const { retry } = require("@octokit/plugin-retry");

const FILE_CONTENTS = "Hello, world!";
const GITHUB_TOKEN = "TOKEN_HERE";

const MyOctokit = Octokit.plugin(retry);
const octokit = new MyOctokit({
  auth: GITHUB_TOKEN,
  request: { retries: 5 },
});

async function main() {
  const files = [
    "test-file-1.txt",
    "test-file-2.txt",
    "test-file-3.txt",
    "test-file-4.txt",
    "test-file-5.txt",
    "test-file-6.txt",
    "test-file-7.txt",
    "test-file-8.txt",
    "test-file-9.txt",
    "test-file-10.txt",
  ];
  await Promise.all(
    files.map(async (file) => {
      await octokit.repos.createOrUpdateFileContents({
        owner: "dcshzj",
        repo: "test",
        path: file,
        message: `Add ${file}`,
        content: Buffer.from(FILE_CONTENTS).toString("base64"),
      });
    })
  );
}

main();

Without the retries, only one file will be created and the rest will have an error. Adding the retry plugin will allow all 10 files to be created successfully.

Deploy Notes

New dependencies:

  • @octokit/plugin-retry : An octokit plugin to automatically retry on retry-able errors.

@dcshzj dcshzj requested a review from a team September 5, 2023 08:57
@dcshzj dcshzj merged commit ae722b9 into develop Sep 6, 2023
@mergify mergify bot deleted the fix/retry-indirection-dns branch September 6, 2023 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants