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

[WIP] fix: Clearer error messaging when VM generation detection goes wrong #138

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bdonaldson77
Copy link

When running a Packer build in a situation where you already have a HyperV VM with the same name as your desired build VM's name, you will receive a cryptic error when Packer attempts to determine the VM's generation to determine its capabilities:

2024-11-18T15:03:35-08:00: Build 'hyperv-vmcx' errored after 55 seconds 702 milliseconds: Error detecting vm generation: strconv.ParseUint: parsing "2\r\n2": invalid syntax

==> Wait completed after 55 seconds 702 milliseconds

==> Some builds didn't complete successfully and had errors:
--> hyperv-vmcx: Error detecting vm generation: strconv.ParseUint: parsing "2\r\n2": invalid syntax

By adding a check to compare the result of the script that detects the generation of the VM to a regex, it does not alter the functionality, but makes it much clearer that the error happened because the VM generation detection script returned an unexpected result.

2024-11-18T15:29:54-08:00: Build 'hyperv-vmcx' errored after 1 minute 5 seconds: Error detecting vm generation: PowerShell error: Unable to parse VM generation. Are there multiple VMs with the same name?

I initially looked at swallowing the error if the results of the generation check were all identical (e.g. if you have 3 VMs and all are generation 2, logically you could return that your VM is generation 2,) but that opens the door to problems later when other commands run against a given VM name and receive multiple results (e.g. powering on all the VMs instead of just the one you wanted.)

@bdonaldson77 bdonaldson77 requested a review from a team as a code owner November 18, 2024 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant