Skip to content
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

vsphere-clone: Unwanted behavior using -force flag when source virtual machine doesn't exist #490

Open
1 of 2 tasks
YuriyAM opened this issue Nov 13, 2024 · 0 comments · May be fixed by #489
Open
1 of 2 tasks

vsphere-clone: Unwanted behavior using -force flag when source virtual machine doesn't exist #490

YuriyAM opened this issue Nov 13, 2024 · 0 comments · May be fixed by #489
Labels
Milestone

Comments

@YuriyAM
Copy link

YuriyAM commented Nov 13, 2024

Overview of the Issue

Currently, when running packer build -force with the vsphere-clone builder, if the specified source virtual machine is missing, Packer proceeds to delete the target virtual machine before verifying that the source is available. This behavior risks data loss, especially in cases where the target VM is unique and has no backup or proper build configuration.

One of the use cases is when Packer is used to regularly update legacy virtual machine templates that are unique and cannot be recreated. Running packer build -force without verifying the source VM can lead to data loss, especially when human error or misconfiguration occurs.

Reproduction Steps

  1. Have a template set to non-existing virtual machine
  2. Run packer build -force
  3. Observe that the target VM is deleted before confirming that a source VM is available.

Expected Behavior

  1. vsphere-clone builder should first check if the source VM exists before force-deleting the target VM.
  2. If the source VM is missing, the build process should exit without affecting the target VM.

Packer Version

Packer v1.11.2

Plugin Version and Builders

Plugin version 1.4.2

  • vsphere-iso
  • vsphere-clone

VMware vSphere Version

Please provide the VMware vSphere version.

  • 7.0.3

Guest Operating System

Any

Simplified Packer Buildfile

Basicvsphere-clone configuration; template option is set to a non-existing virtual machine.

Operating System and Environment Details

Any

Log Fragments and crash.log Files

2024-11-11T07:39:34Z: ==> vsphere-clone.vm: the vm/template packer-live-folder/packer-test-vm already exists, but deleting it due to -force flag
2024-11-11T07:39:34Z: ==> vsphere-clone.vm: packer-live-folder/packer-test-vm is a template, attempting to convert it to a vm
2024-11-11T07:39:36Z: ==> vsphere-clone.vm: Cloning virtual machine...
2024-11-11T07:39:36Z:     vsphere-clone.vm: Closing sessions ....
2024-11-11T07:39:36Z: Build 'vsphere-clone.vm' errored after 1 second 989 milliseconds: error finding virtual machine to clone: vm 'packer-build-folder/packer-test-vm' not found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants