-
Notifications
You must be signed in to change notification settings - Fork 92
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
Use correct VMDK sizes when building OVA #1831
Conversation
@@ -135,7 +135,10 @@ function main { | |||
log1 "packaging OVA..." | |||
cp "${DIR}"/config/builder.ovf "${PACKAGE}/vic-${BUILD_OVA_REVISION}.ovf" | |||
cd "${PACKAGE}" | |||
sed -i -e s~--version--~${BUILD_OVA_REVISION}~ vic-${BUILD_OVA_REVISION}.ovf | |||
sed -i -e s~--version--~${BUILD_OVA_REVISION}~ \ | |||
-e "/<File.*vic-disk1.vmdk.*/s|ovf:size=\"[^\"]*\"|ovf:size=\"$(stat --printf="%s" vic-disk1.vmdk)\"|" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the same separator characters as above and a space between the filter and the replacement:
-e "/<File.*vic-disk1.vmdk.*/ s~ovf:size=\"[^\"]*\"~ovf:size=\"$(stat --printf="%s" vic-disk1.vmdk)\"~"
Add an array of the expected disks and loop over it. Multiple sed passes are a fine cost to pay for increased clarity.
log2 "updating version number" | ||
sed -i -e "s|--version--|${BUILD_OVA_REVISION}|" vic-${BUILD_OVA_REVISION}.ovf | ||
log2 "updating disk sizes" | ||
DISKS=("vic-disk1.vmdk" "vic-disk2.vmdk") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of this logic could all probably go in https://github.com/zjs/vic-product/blob/22cc2ea882424c0b3cf0b80b132d239e8ca73201/installer/build/bootable/build-disks.sh#L208 where disk names are already listed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like listing the disk names in three places (the OVF, build-main.sh
, and build-disks.sh
), like my current change does.
However, one thing that I like about the current design is that build-disks.sh
and build-main.sh
seem to have fairly separate purposes: one creates the VMDKs, while the other bundles them into an OVA.
I'm not sure how important that distinction is in practice, but I worry that moving this logic into build-disks.sh
blurs the line too much.
Perhaps build-main.sh
should update the disk sizes, but not have a hardcoded value for DISKS
. Instead, it could just base the array on the contents of the directory. This is a little fragile (what happens if there's something unexpected in the directory?), but may be better than explicitly listing the names in multiple places. (On the other hand, explicitly referring to them my name makes it easy for someone to grep for them by name and find this logic.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair concerns about blurring the separation of logic between build-main and build-disks.
My original intent was to have all bull attributes (disk size, names, etc) parsed and read from ether a json file or the ovf template in build-main, and passed to the other builder scripts.
Something similar could be done here - just pass the newly-defined disk array you’ve added in build-main as an argument in calls to build-disk. That preserves the separation of logic while removing one repeated definition of the disks array.
Furthermore, it serves as a good stepping stone to eventually reading those values from the ovf config in build-main and passing them to any desired subsequent build step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did basically what you describe, except to avoid separating the disk names from the other information about them, I moved all three arrays into build-main. I think this is consistent with the idea of eventually reading the values from somewhere (JSON or OVF).
22cc2ea
to
514f8ae
Compare
The builder OVF used to construct the OVA has hard-coded disk sizes. Correct these to match the final size of the VMDKs to avoid warnings during the OVA deployment process.
Refactor to pass image data from build-main to build-disks to avoid duplication of image names.
2464a5e
to
d680c8a
Compare
|
||
# check there were no extra args and the required ones are set | ||
if [[ -n "$*" || -z "${PACKAGE}" || -z "${ACTION}" ]]; then | ||
if [[ -n "$*" || -z "${PACKAGE}" || -z "${ACTION}" || ${#IMAGES[@]} -eq 0 || ${#IMAGESIZES[@]} -eq 0 || ${#IMAGEROOTS[@]} -eq 0 ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a purely pedantic perspective, these should be tested for equality with each other as well as !0
sha256sum --tag "vic-${BUILD_OVA_REVISION}.ovf" *.vmdk | sed s/SHA256\ \(/SHA256\(/ > "vic-${BUILD_OVA_REVISION}.mf" | ||
tar -cvf "${RESOURCE}/vic-${BUILD_OVA_REVISION}.ova" "vic-${BUILD_OVA_REVISION}.ovf" "vic-${BUILD_OVA_REVISION}.mf" *.vmdk | ||
sha256sum --tag "vic-${BUILD_OVA_REVISION}.ovf" "${IMAGEFILES[@]}" | sed s/SHA256\ \(/SHA256\(/ > "vic-${BUILD_OVA_REVISION}.mf" | ||
tar -cvf "${RESOURCE}/vic-${BUILD_OVA_REVISION}.ova" "vic-${BUILD_OVA_REVISION}.ovf" "vic-${BUILD_OVA_REVISION}.mf" "${IMAGEFILES[@]}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This cannot be compressed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed #1837 to track.
The builder OVF used to construct the OVA has hard-coded disk sizes. Correct these to match the final size of the VMDKs to avoid warnings during the OVA deployment process. Refactor to pass image data from build-main to build-disks to avoid duplication of image names. (cherry picked from commit 62bccb8)
The builder OVF used to construct the OVA has hard-coded disk sizes. Correct these to match the final size of the VMDKs to avoid warnings during the OVA deployment process. Refactor to pass image data from build-main to build-disks to avoid duplication of image names. (cherry picked from commit 62bccb8)
The builder OVF used to construct the OVA has hard-coded disk sizes. Correct these to match the final size of the VMDKs to avoid warnings during the OVA deployment process. Refactor to pass image data from build-main to build-disks to avoid duplication of image names. (cherry picked from commit 62bccb8)
The builder OVF used to construct the OVA has hard-coded disk sizes. Correct these to match the final size of the VMDKs to avoid warnings during the OVA deployment process. Refactor to pass image data from build-main to build-disks to avoid duplication of image names. (cherry picked from commit 62bccb8)
The builder OVF used to construct the OVA has hard-coded disk sizes. Correct these to match the final size of the VMDKs to avoid warnings during the OVA deployment process. Refactor to pass image data from build-main to build-disks to avoid duplication of image names. (cherry picked from commit 62bccb8)
The builder OVF used to construct the OVA has hard-coded disk sizes. Correct these to match the final size of the VMDKs to avoid warnings during the OVA deployment process. Refactor to pass image data from build-main to build-disks to avoid duplication of image names. (cherry picked from commit 62bccb8)
The builder OVF used to construct the OVA has hard-coded disk sizes. Correct these to match the final size of the VMDKs to avoid warnings during the OVA deployment process.
VIC Appliance Checklist:
master
branchIf this is a feature or change to existing functionality, consider areas of impact with the Impact
Assessment Checklist
Fixes #1166