-
Notifications
You must be signed in to change notification settings - Fork 42
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
Fix handling of temporary cdrom devices #31
Conversation
There was a previous attempt to do this in step_configure_vmx, but that only covers vmware-iso (missing potential cases when using cd_files/cd_content in vmware-vmx) and it had the wrong device name (would mark <type>0:<primary> as temporary when the device name used for cd_path is actually <type>1:<primary>
ParseVMX/EncodeVMX force the keys to lowercase, so inserting with a mixed-case key fails to replace existing values, resulting in duplicate lines and vmware potentially still using the previous filename
Hmm, just noticed one flaw in this PR - StepConfigureVMX actually runs twice: packer-plugin-vmware/builder/vmware/vmx/builder.go Lines 103 to 109 in e38fb92
packer-plugin-vmware/builder/vmware/vmx/builder.go Lines 166 to 170 in e38fb92
And the CD data is set both times, so it actually attempts to overwrite itself (harmless, if a little weird), but that now means it adds and that's confirmed in the log:
It looks like floppy avoids this because of SkipFloppy - I wonder if we should just generalize that to SkipDevices, since it really doesn't make sense create temp devices right before (with nothing in between) StepCleanVmx. The later StepConfigureVMX is just setting the VMXDataPost (and, for some reason, resetting the name and DisplayName) packer-plugin-vmware/builder/vmware/common/step_configure_vmx.go Lines 80 to 81 in e38fb92
Cleaning up is idempotent, so doing it twice is better than zero times like before, but that's a little untidy. |
It's not just floppies, it doesn't make sense to create any new temporaryDevices in between StepCleanFiles and StepCleanVMX.
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.
Hey @puetzk, super nice, this LGTM & worked on my machine ! Thanks for your time again 🙂
// StepConfigureVMX runs both before and after provisioning (for VmxDataPost), | ||
// the latter time shouldn't create temporary devices | ||
if !s.SkipDevices { |
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.
👍🏼
Ftr, there was some further discussion in #31 that might affect this PR. So I'm noting it in this PR's history despite it already being merged. |
@azr: Ah, yes. My bad. |
Fix two more issues with vmware and cd_{files,content}
if a temporary cdPath is set up, during step_configure_vmx, it should be claned up by step_clean_vmx
There is already code to do this cleanup, but it wasn't triggering because it was only applied to vmware-iso (and had the wrong device name there). Only floppies were added to temporaryDevices when the setup was actually being done.
Fix updating/overwriting existing cdrom device properties (case-sensitivity)
packer lowercases all the vmx keys when reading a file in:
packer-plugin-vmware/builder/vmware/common/vmx.go
Line 28 in e38fb92
so using mixed-case keys to update the .vmx introduces semantic duplicates (rather than replacing old values)
packer-plugin-vmware/builder/vmware/common/step_configure_vmx.go
Lines 94 to 95 in e38fb92