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

Non-GitHub Updates #1535

Merged
merged 39 commits into from
Jun 11, 2023
Merged

Non-GitHub Updates #1535

merged 39 commits into from
Jun 11, 2023

Conversation

Cyberboss
Copy link
Member

@Cyberboss Cyberboss commented Jun 11, 2023

Closes #1495

🆑
Server update packages can now be provided through the API. Note that if an update package that doesn't match the tgstation-server update protocol is uploaded or if the actual uploaded version doesn't match the version specified in the POST API request, undefined behavior will occur.
Fixed an error that occurred if a static file upload ticket was abandoned.
Fixed potential memory leak in the non-GitHub OAuth login procedures.
Minor performance improvement in the non-GitHub OAuth login procedures.
Fixed double read occurring when downloading log files through the API.
Swarm distributed update downloads are now only performed on the initiating server. Other servers then download the update package from the initiator.
Fixed several edge cases in swarm distributed update process.
/:cl:

🆑 HTTP API
Added Administration right 128 for uploading custom server update packages.
POST /Administration now accepts a boolean uploadZip field. If set, and the request succeeds, a fileTicket will be generated in the response. This ticket can be used to upload a .zip server update package using the /Transfer route.
/:cl:

API/Client releases pending #1464

- Use generic `Stream`s where possible instead of `FileStream`s.
- Split stream provider logic from `IFileUploadTicket`.
- File upload tickets implement `IAsyncDisposable` instead of `IDisposable`
- Move SetError up to IFileUploadTicket.
- Move from Transfer to IO namespace.
- `DelayedFileDownloader` changed into `RequestFileStreamProvider` which provides a direct network stream.
- `CachedResponseStream` now only caches the `HttpContent` as opposed to the `HttpResponseMessage`.
- `IFileDownloader` now synchronously returns `IFileStreamProvider`s.
- `FileDownloader` now returns `RequestFileStreamProviders`.
- Added `ISeekableFileStreamProvider`.
- BufferedFileStreamProvider now implements `ISeekableFileStreamProvider`.
When running a distributed swarm server update, only the initiator server will download the update package directly from GitHub. It will then make the package available to the other nodes via a `SwarmController` hosted variant of the `FileTransferService` which they will use to retrieve their copies of the package.

Because of this, it's possible for the update package to be accessed via the regular `TransferController` duing this process. This is acceptable for three reasons:

- We use crytographically secure strings for the transfer service tickets
- If a malicious user steals one or more of the Swarm's update package tickets, the update will simply be aborted.
- An update package is not considered secure data what with this being OSS.
- Extract dubiously guarded `SwarmService` variables into `volatile` handler class with `Interlocked` writes.
- `SwarmService.Abort` can no longer be cancelled, but it short circuits more easily.
- Improved `SwarmRpcMapper`'s handling of `CancellationToken`s.
This stops a class coupling warning.
- Move classes to `Http` namespace.
- Give it a unique package version.
- Comment to make me not rage update Nuget libs to .NET 6.
- New `ServerUpdateRequest` field `uploadZip`.
- New Administration permission for this.
- `ServerUpdateResponse` will now contain a transfer ticket if set.
- Live tests.

This is super easy after the work done in 09208ad
@Cyberboss Cyberboss added Refactor Refactor functionality for future improvements Client Issue with the .NET client library Fix Fixes incorrect functionality labels Jun 11, 2023
src/Tgstation.Server.Host/Core/ServerUpdater.cs Dismissed Show dismissed Hide dismissed
src/Tgstation.Server.Host/Swarm/SwarmService.cs Dismissed Show dismissed Hide dismissed
src/Tgstation.Server.Host/Swarm/SwarmService.cs Dismissed Show dismissed Hide dismissed
src/Tgstation.Server.Host/Swarm/SwarmService.cs Dismissed Show dismissed Hide dismissed
github-actions[bot]
github-actions bot previously approved these changes Jun 11, 2023
github-actions[bot]
github-actions bot previously approved these changes Jun 11, 2023
github-actions[bot]
github-actions bot previously approved these changes Jun 11, 2023
github-actions[bot]
github-actions bot previously approved these changes Jun 11, 2023
github-actions[bot]
github-actions bot previously approved these changes Jun 11, 2023
@codecov
Copy link

codecov bot commented Jun 11, 2023

Codecov Report

Merging #1535 (cc6833a) into dev (3c77941) will increase coverage by 0.03%.
The diff coverage is 79.16%.

@@            Coverage Diff             @@
##              dev    #1535      +/-   ##
==========================================
+ Coverage   72.52%   72.55%   +0.03%     
==========================================
  Files         357      364       +7     
  Lines       21918    22346     +428     
==========================================
+ Hits        15896    16214     +318     
- Misses       6022     6132     +110     

@Cyberboss Cyberboss merged commit 5e6dc42 into dev Jun 11, 2023
74 checks passed
@Cyberboss Cyberboss deleted the 1495-NonGitHubUpdates branch June 11, 2023 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client Issue with the .NET client library Feature New functionality Fix Fixes incorrect functionality HTTP API The JSON Web API that controls the server Refactor Refactor functionality for future improvements Swarm Related to server swarm feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow updating from sources other than GitHub
1 participant