Fit disk size to source image by default - #356
Open
ExplorerRay wants to merge 2 commits into
Open
Conversation
Signed-off-by: Ray Huang <bjhuang@cs.nycu.edu.tw>
Signed-off-by: Ray Huang <bjhuang@cs.nycu.edu.tw>
|
Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement Learn more about why HashiCorp requires a CLA and what the CLA includes Have you signed the CLA already but the status is still pending? Recheck it. |
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.
Description
I found that this builder will use 20GB when not specified image
disk_sizeand I met an issue that my source image is using a disk with 430GB which GCE reports me 20GB is unavailable to build. Working around it means looking up the image's size and hardcoding it into the template, so I think defaulting to the source image size is the better behavior.With the help of Claude, I made
Config.Preparestop defaultingdisk_sizeto 20, which lets an unset value reach the build as0.StepCreateInstancethen resolves it againstsourceImage.SizeGb, which the driver already populates from the image'sdiskSizeGb. If the source image reports no size, it falls back to a newdefaultDiskSizeGbconstant of 20GB, matching the original behavior.An explicitly set
disk_sizeis passed through unchanged, including a value smaller than the source image — that still fails at the GCE API exactly as it does today. I left it that way deliberately, but I'm happy to add a clearer error message or grow the disk automatically if reviewers prefer. Maybe we can add a fail-fast mechanism inresolveDiskSize().One behavior change worth flagging: with
disk_sizeunset and a source image smaller than 20GB, the boot disk is now the image's size rather than 20GB. Builds that relied on that extra headroom will need to setdisk_sizeexplicitly.Also added
TestResolveDiskSize,TestStepCreateInstance_diskSize, andTestConfigPrepare_DiskSizeDefault.go test ./...passes and the docs were regenerated withmake generate.Resolved Issues
No. I didn't create an issue before making this change.
Rollback Plan
If a change needs to be reverted, we will roll out an update to the code within 7 days.
Changes to Security Controls
No. This reuses the existing code path that fetches image information.