Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

github: fix erratic 404s by keeping URL stable#56478

Merged
mrnugget merged 1 commit into
mainfrom
mrn/fix-url-modified
Sep 11, 2023
Merged

github: fix erratic 404s by keeping URL stable#56478
mrnugget merged 1 commit into
mainfrom
mrn/fix-url-modified

Conversation

@mrnugget

@mrnugget mrnugget commented Sep 8, 2023

Copy link
Copy Markdown
Contributor

See this comment and the issue it's in for full context.

Short version:

  1. GitHub v3 and v4 clients execute this bit of code multiple times when retrying a request after it ran into rate limits: https://github.com/sourcegraph/sourcegraph/blob/16458d7e5c07ac69d00d32841a1a7dcd55a50ddb/internal/extsvc/github/common.go#L1589-L1590
  2. When executed multiple times with the same url.URL, req.URL.Path ends up with invalid paths like /api/v3/api/v3

That lead to 404 errors showing up sometimes: when the client runs into rate limit and retries. And sometimes these 404s were even ignored and lead to a "successful" end of the syncing process.

This changes the behaviour of the clients to keep a copy of the original req.URL around so that modifications made by doRequest don't have unintended side-effects.

Test plan

  • Existing and new tests

@mrnugget mrnugget requested review from a team and keegancsmith September 8, 2023 15:38
@cla-bot cla-bot Bot added the cla-signed label Sep 8, 2023
@sourcegraph-bot

sourcegraph-bot commented Sep 8, 2023

Copy link
Copy Markdown
Contributor

Codenotify: Notifying subscribers in CODENOTIFY files for diff ad1e9a9...8484d15.

Notify File(s)
@eseliger internal/extsvc/github/v3.go
internal/extsvc/github/v3_test.go
internal/extsvc/github/v4.go
internal/extsvc/github/v4_test.go

@eseliger eseliger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tests!

Changelog entry + backport?

See [this comment](sourcegraph/customer#2329 (comment))
and the issue it's in for full context.

Short version:

1. GitHub v3 and v4 clients execute this bit of code multiple times when retrying a request after it ran into rate limits: https://github.com/sourcegraph/sourcegraph/blob/16458d7e5c07ac69d00d32841a1a7dcd55a50ddb/internal/extsvc/github/common.go#L1589-L1590
2. When executed multiple times with the same `url.URL`, `req.URL.Path` ends up with invalid paths like `/api/v3/api/v3`

That lead to 404 errors showing up _sometimes_: when the client runs
into rate limit and retries. And _sometimes_ these 404s were even
ignored and lead to a "successful" end of the syncing process.

This changes the behaviour of the clients to keep a copy of the original
`req.URL` around so that modifications made by `doRequest` don't have
unintended side-effects.
@mrnugget

Copy link
Copy Markdown
Contributor Author

Changelog entry + backport?

Done and on the way

@mrnugget mrnugget merged commit 8e21962 into main Sep 11, 2023
@mrnugget mrnugget deleted the mrn/fix-url-modified branch September 11, 2023 08:27
@sourcegraph-release-bot

sourcegraph-release-bot commented Sep 11, 2023

Copy link
Copy Markdown
Collaborator

The backport to 5.1 failed at https://github.com/sourcegraph/sourcegraph/actions/runs/6143880704:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-5.1 5.1
# Navigate to the new working tree
cd .worktrees/backport-5.1
# Create a new branch
git switch --create backport-56478-to-5.1
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 8e219623bab03cc15c520f9b2d9012ebd3f759c9
# Push it to GitHub
git push --set-upstream origin backport-56478-to-5.1
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-5.1

If you encouter conflict, first resolve the conflict and stage all files, then run the commands below:

git cherry-pick --continue
# Push it to GitHub
git push --set-upstream origin backport-56478-to-5.1
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-5.1
  • Follow above instructions to backport the commit.
  • Create a pull request where the base branch is 5.1 and the compare/head branch is backport-56478-to-5.1., click here to create the pull request.
  • Make sure to tag @sourcegraph/release-guild in the pull request description.
  • Once the backport pull request is created, kindly remove the release-blocker from this pull request.

@sourcegraph-release-bot sourcegraph-release-bot added backports failed-backport-to-5.1 release-blocker Prevents us from releasing: https://about.sourcegraph.com/handbook/engineering/releases labels Sep 11, 2023
mrnugget added a commit that referenced this pull request Sep 11, 2023
See [this comment](sourcegraph/customer#2329 (comment))
and the issue it's in for full context.

Short version:

1. GitHub v3 and v4 clients execute this bit of code multiple times when retrying a request after it ran into rate limits: https://github.com/sourcegraph/sourcegraph/blob/16458d7e5c07ac69d00d32841a1a7dcd55a50ddb/internal/extsvc/github/common.go#L1589-L1590
2. When executed multiple times with the same `url.URL`, `req.URL.Path` ends up with invalid paths like `/api/v3/api/v3`

That lead to 404 errors showing up _sometimes_: when the client runs
into rate limit and retries. And _sometimes_ these 404s were even
ignored and lead to a "successful" end of the syncing process.

This changes the behaviour of the clients to keep a copy of the original
`req.URL` around so that modifications made by `doRequest` don't have
unintended side-effects.

(cherry picked from commit 8e21962)
@mrnugget

Copy link
Copy Markdown
Contributor Author

manually created backport here: https://github.com/sourcegraph/sourcegraph/pull/56495/files

@mrnugget mrnugget removed the release-blocker Prevents us from releasing: https://about.sourcegraph.com/handbook/engineering/releases label Sep 11, 2023
BolajiOlajide added a commit that referenced this pull request Sep 11, 2023
…6495)

Co-authored-by: Bolaji Olajide <25608335+BolajiOlajide@users.noreply.github.com>
fix erratic 404s by keeping URL stable (#56478)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants