fix: vsphere-clone: rearrange build steps to ensure source VM exists before deleting target#489
Conversation
|
Could you please link this pull request to an issue? |
|
@tenthirtyam I couldn’t find any open or closed issue that this merge request directly relates to. If it’s required by your procedures, I’d be happy to create one 😊 |
|
yes, please. This is mentioned in the contributed guidelines. 😉 |
|
I might have overlooked that 😅 Thanks for guiding me! Here’s the link to the issue—#490 |
lbajolet-hashicorp
left a comment
There was a problem hiding this comment.
Hey @YuriyAM,
At first glance this looks good to me, I'll defer to @tenthirtyam to give his opinion on the code before we can consider merging this PR, but on my end LGTM!
…e deleting target
|
@lbajolet-hashicorp - ready for your review again. |
lbajolet-hashicorp
left a comment
There was a problem hiding this comment.
Thanks for the reroll and the pings @tenthirtyam @YuriyAM, the code looks good to me in the current state, and since the tests are all green, we can merge this one now!
|
I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Summary
This PR addresses an issue in the
vsphere-clonebuilder where using the-forceflag can lead to unintentional deletion of the target VM, which may result in the loss of critical data if the target VM is the only copy of a virtual machine.Issue description
Currently, when the
-forceflag is specified, thevsphere-clonebuilder first deletes the target VM before verifying that the source VM to be cloned exists. If the source VM is missing, this process leaves users without a VM to clone and potentially results in data loss.Use case
In our environment, Packer is used to perform regular updates on legacy virtual machine templates. These templates are unique, lack proper build configurations, and cannot be easily replicated. If, for any reason, human intervention results in running
packer buildwith the-forceflag, there is a significant risk of losing irreplaceable data.Testing
Testing was performed to confirm:
-forceflag, the target VM is only deleted if a source VM exists.Related issues
vsphere-clone: Unwanted behavior using-forceflag when source virtual machine doesn't exist #490