-
Notifications
You must be signed in to change notification settings - Fork 106
fix: vsphere-clone: rearrange build steps to ensure source VM exists before deleting target
#489
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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!
tenthirtyam
left a comment
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.
LGTM
…e deleting target
|
@lbajolet-hashicorp - ready for your review again. |
lbajolet-hashicorp
left a comment
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.
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!
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