fix: change default artifact temp dir to storage partition to prevent…#246
fix: change default artifact temp dir to storage partition to prevent…#246Jxt-Eli wants to merge 1 commit into
Conversation
… disk full errors during extraction
There was a problem hiding this comment.
Pull request overview
This PR changes CubeMaster’s rootfs artifact work directory default so template image extraction uses the artifact storage partition instead of /tmp, reducing root partition space pressure during template creation.
Changes:
- Defaults
artifactWorkRootDir()to atmp/cubemaster-rootfs-artifactsdirectory under the configured artifact store root. - Documents a storage free-space recommendation for template creation in the README.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| README.md | Adds a note recommending at least 20GB free on the CubeMaster storage partition. |
| CubeMaster/pkg/templatecenter/template_image.go | Changes the default artifact work directory from OS temp to the artifact store partition. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| storeRoot := artifactStoreRootDir() | ||
| return filepath.Join(storeRoot, "tmp", "cubemaster-rootfs-artifacts") |
|
/cubebot review |
|
Claude finished @fslongjin's task in 2m 14s —— View job Review of #246Thanks for the PR, @Jxt-Eli! This is a well-motivated change — moving temp artifacts off the root partition to prevent disk-full failures during template extraction is a solid improvement. Change Summary
Code QualityThe implementation is clean and follows the existing patterns well. A few observations: 1. Copilot reviewer's concern — fallback path mismatch The copilot reviewer correctly identified that
Suggested fix: Derive the work directory from the resolved store root so that both paths stay on the same filesystem. In func buildRootfsArtifact(ctx context.Context, record *models.RootfsArtifact, ...) {
storeDir, err := resolveArtifactStoreDir(ctx, record.ArtifactID)
if err != nil {
return nil, nil, err
}
// Derive work dir from resolved store root so extraction stays
// on the same filesystem as the final artifact, even on fallback.
storeRoot := filepath.Dir(storeDir)
workDir := filepath.Join(storeRoot, "tmp", "cubemaster-rootfs-artifacts", record.ArtifactID)
rootfsDir := filepath.Join(workDir, "rootfs")
storeRootfsDir := filepath.Join(storeDir, "rootfs")
...
}This keeps the work directory on the same filesystem as the final store in both primary and fallback scenarios. 2. Minor: README note placement The README note about storage space is useful, but it might be more discoverable if placed closer to the template creation instructions (around line 196 or 215) rather than in the general storage note section. Consider moving it. 3. Cross-device copy optimization The PR description correctly notes that keeping intermediate files on the same disk avoids cross-device copies. This works because Testing NotesThis is difficult to unit-test locally since it depends on filesystem state. In production/staging environments, verify:
Overall this is a well-structured first contribution. The code is concise, the motivation is clear, and the change is scoped appropriately. Nice work! |
|
Hi @Jxt-Eli, Thanks for the PR! The DCO (Developer Certificate of Origin) check is failing. You need to add a You can fix this by amending your commit: git commit --amend --signoff
git push --forceThis will append a |
|
Hi @Jxt-Eli, Thanks for the PR. I think the current approach works around the issue rather than addressing the root cause. Silently changing the default temp dir to the storage partition changes behavior in a way that may not be expected. I think a more robust solution would be to add disk space detection — check available space before template creation and fail early with a clear error message if there isn't enough room, rather than letting it fail halfway with a confusing error. This way users know exactly what to fix (e.g., free up space or configure Would you be interested in exploring this approach? |
… disk full errors during extraction
Fixes #240
What this PR does:
This PR addresses the issue where template creation fails due to
/tmprunning out of space.Instead of defaulting to
os.TempDir()(which would cause issues when disk space isn't enough),artifactWorkRootDir()intemplate_image.gowill now dynamically default to creating atmpfolder inside the configuredartifactStoreRootDirunless an environment variable is explicitly set by the user.Why this is better:
(Note: This is my first open-source contribution! Let me know if any changes are needed to the code style or structure.)