fix: Clearer error messaging when VM generation detection goes wrong#138
Open
bdonaldson77 wants to merge 1 commit intohashicorp:mainfrom
Open
fix: Clearer error messaging when VM generation detection goes wrong#138bdonaldson77 wants to merge 1 commit intohashicorp:mainfrom
bdonaldson77 wants to merge 1 commit intohashicorp:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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.
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.)