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

Add Support for Archive Uploads to GitHub-Owned Storage with Multipart Upload Option #1261

Closed
wants to merge 16 commits into from

Conversation

hfishback01
Copy link
Contributor

@hfishback01 hfishback01 commented Sep 5, 2024

Summary:

This PR introduces the ability for the GEI CLI to upload archives to GitHub-owned storage using multipart uploads. To enable this, a new CLI option, --use-github-storage, has been added. This option allows users to explicitly specify that their archives should be uploaded to GitHub's managed storage instead of their own.

Key Features:

Multipart Upload Support: Leveraging multipart upload for reliable and efficient large file uploads. This ensures the robustness of the uploads, minimizing the chances of failure during transmission. We're investigating libraries to handle multipart uploads, but for now, this feature is not rolled by hand unless necessary.

New Option: --use-github-storage:

This option is required to upload archives to GitHub-owned storage and will be hidden until GitHub-owned storage reaches general availability (GA).
By default, archives are still uploaded to user-specified storage locations unless the --use-github-storage flag is explicitly set.

Motivation:

As discussed during our EDR, we want to allow users to utilize GitHub-owned storage as an option without making it the default. This approach lets us roll out GitHub-managed storage in stages and gather feedback while providing an explicit way to opt-in to this feature.

Check in BBS MigrateRepoCommandArgs removed, relating to changes in this PR: #1057

Take it out for a 🚗 :

Migrating from GitHub Enterprise Server:

dotnet run --project src/gei/gei.csproj -- migrate-repo --github-source-org valet-testing --source-repo integration-tests --github-target-org octoshift-staging --target-repo YOU_ADD_NEW_NAME--use-github-storage true --ghes-api-url https://octoshift-ghe.westus2.cloudapp.azure.com/api/v3 --verbose

Successful migration_id: RM_kgHaACQxMWNjY2RlMi1hNTAzLTQwMWItOTA1OS1kM2NkZjBiYjM4Y2Q

Closes: https://github.ghe.com/github/octoshift/issues/8969

  • Did you write/update appropriate tests
  • Release notes updated (if appropriate)
  • Appropriate logging output
  • Issue linked
  • Docs updated (or issue created)
  • New package licenses are added to ThirdPartyNotices.txt (if applicable)

Copy link

github-actions bot commented Sep 5, 2024

Unit Test Results

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit 25ea598.

♻️ This comment has been updated with latest results.

@@ -198,6 +200,22 @@ private async Task<string> UploadArchiveToAws(string bucketName, string archiveP
return archiveBlobUrl;
}

private async Task<string> UploadArchiveToGithub(string org, string archivePath)
{
#pragma warning disable IDE0063
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason the warning was disabled? I think we can use using declaration here.

src/gei/Commands/MigrateRepo/MigrateRepoCommand.cs Outdated Show resolved Hide resolved
src/gei/Commands/MigrateRepo/MigrateRepoCommandHandler.cs Outdated Show resolved Hide resolved
src/gei/Commands/MigrateRepo/MigrateRepoCommandHandler.cs Outdated Show resolved Hide resolved
src/gei/Commands/MigrateRepo/MigrateRepoCommandHandler.cs Outdated Show resolved Hide resolved
Copy link
Collaborator

@ArinGhazarian ArinGhazarian left a comment

Choose a reason for hiding this comment

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

Dropped a couple more comments.

src/Octoshift/Services/GithubApi.cs Outdated Show resolved Hide resolved
{ httpContent, "archive", archiveName }
};

response = await _client.PostAsync(url, content);
Copy link
Collaborator

@ArinGhazarian ArinGhazarian Sep 12, 2024

Choose a reason for hiding this comment

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

A couple of observations:

  1. Even though this may work the PostAsync method will convert the data to JSON (basically base64 string) and will eventually create StringContent so I am not sure if this is the intended use here because we're now dealing with a Stream rather than string content. So We may want to refactor the SendAsync method to also support a MultiPartFormDataContent and StreamContent. It can simply check to see if the passed in body is either of those and not convert it to a string content.
  2. When dealing with a stream we shouldn't log the entire body as we do here instead as I suggested in option 1, we can check the body and if it's a multipart form data or a stream content we can just say BLOB or Binary data instead of dumping the entire JSON encoded body!

@begonaguereca begonaguereca changed the title Initial commit Add Support for Archive Uploads to GitHub-Owned Storage with Multipart Upload Option Sep 24, 2024
Copy link

Code Coverage

Package Line Rate Branch Rate Complexity Health
bbs2gh 79% 74% 658
ado2gh 84% 78% 627
Octoshift 86% 76% 1274
gei 80% 71% 534
Summary 83% (6867 / 8239) 75% (1550 / 2062) 3093

@begonaguereca begonaguereca marked this pull request as draft September 25, 2024 14:10
@begonaguereca begonaguereca changed the base branch from main to git-storage-option-feature October 8, 2024 17:51
@begonaguereca begonaguereca changed the base branch from git-storage-option-feature to main October 8, 2024 17:59
@begonaguereca begonaguereca changed the base branch from main to git-storage-option-feature October 8, 2024 17:59
@hfishback01 hfishback01 closed this Oct 8, 2024
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.

3 participants