fix(media): add USB size and cache space safeguards#167
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds safety checks around USB boot media creation (minimum supported USB size) and improves deployment robustness by falling back to the target disk cache when the USB cache partition lacks free space, while adding regression coverage for both behaviors.
Changes:
- OSD: Introduce a minimum USB disk size (16 GiB) as a blocking reason for USB creation while keeping the device visible in readiness UI.
- Core: Add a final disk-safety guard in
WinPeUsbMediaServiceto refuse targets below the minimum size. - Deploy: Add size-aware cache-root resolution that can fall back from USB cache to target cache; add tests covering fallback behavior.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Foundry/ViewModels/StartMediaViewModel.cs | Updates USB readiness row to show warning state/message when selected USB is below minimum size. |
| src/Foundry/Strings/fr-FR/Resources.resw | Adds localized text for the new blocking reason. |
| src/Foundry/Strings/en-US/Resources.resw | Adds localized text for the new blocking reason. |
| src/Foundry.Deploy/Services/Deployment/Steps/DownloadOperatingSystemImageStep.cs | Uses size-aware cache-root resolution for OS image download. |
| src/Foundry.Deploy/Services/Deployment/Steps/DownloadDriverPackStep.cs | Uses size-aware cache-root resolution for driver pack download. |
| src/Foundry.Deploy/Services/Deployment/DeploymentStepExecutionContext.cs | Adds payload cache root fallback logic based on available free space. |
| src/Foundry.Deploy.Tests/DeploymentPayloadCacheFallbackTests.cs | Adds tests validating USB-cache-to-target-cache fallback for OS/driver pack downloads. |
| src/Foundry.Core/Services/WinPe/WinPeUsbMediaService.cs | Adds minimum USB size constant + disk safety validation guard. |
| src/Foundry.Core/Services/Media/MediaPreflightService.cs | Adds preflight blocking reason for USB targets below minimum size. |
| src/Foundry.Core/Services/Media/MediaPreflightBlockingReason.cs | Adds UsbTargetBelowMinimumSize enum value. |
| src/Foundry.Core.Tests/WinPe/WinPeUsbMediaServiceTests.cs | Adds/adjusts tests for the new minimum-size disk safety validation. |
| src/Foundry.Core.Tests/Media/MediaPreflightServiceTests.cs | Adds coverage ensuring small USB blocks USB creation but not ISO. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1406
to
1409
| string description = isBelowMinimumSize | ||
| ? GetBlockingReasonText(MediaPreflightBlockingReason.UsbTargetBelowMinimumSize) | ||
| : state == StartReadinessState.Ready | ||
| ? FormatUsbCandidate(options.SelectedUsbDisk) |
Comment on lines
20
to
24
| protected override async Task<DeploymentStepResult> ExecuteLiveAsync(DeploymentStepExecutionContext context, CancellationToken cancellationToken) | ||
| { | ||
| string osDirectory = context.ResolveOperatingSystemCacheRoot(); | ||
| string osDirectory = context.ResolveOperatingSystemCacheRoot(context.Request.OperatingSystem.SizeBytes); | ||
| Directory.CreateDirectory(osDirectory); | ||
| const string stepMessage = "Downloading OS image..."; |
Comment on lines
81
to
85
| string driverPackDirectory = Path.Combine( | ||
| context.ResolveDriverPackCacheRoot(), | ||
| context.ResolveDriverPackCacheRoot(driverPack.SizeBytes), | ||
| DeploymentStepExecutionContext.SanitizePathSegment(driverPack.Manufacturer)); | ||
| Directory.CreateDirectory(driverPackDirectory); | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add USB media safety checks and deployment cache fallback behavior.
Reason
Foundry OSD should prevent creating boot media on USB keys smaller than 16 GB while still making the selected device and reason visible to the user. Foundry Deploy should avoid failing deployment downloads when the USB cache does not have enough free space.
Main changes
Testing notes
git diff --checkdotnet test src\Foundry.Core.Tests\Foundry.Core.Tests.csproj --no-restore -m:1 -nr:false(180 passed)dotnet test src\Foundry.Deploy.Tests\Foundry.Deploy.Tests.csproj --no-restore -m:1 -nr:false(108 passed)dotnet build src\Foundry\Foundry.csproj --no-restore -m:1 -nr:false(0 warnings, 0 errors)