Closed cbj4074 closed 5 years ago
I would need to research what the Hyper-V version differences are. I've always used the latest because that meant big features were supported (things we take for granted in other providers).
@vongrippen Beat me to it! I was about to post the same resource.
If lowering the supported version requirement is as simple as adjusting a value in the Packer template, I'm good with that. I wouldn't be interested in trying to downgrade Windows though to accomplish this.
Definitely not; you could still use the latest version of Windows 10, per the description you gave in your previous post(s). The configuration version is fully backwards-compatible, so you could use any higher version of Windows 10 to bake an image with a lower configuration version.
On the Powershell side, specifying the VM's configuration version looks to be as simple as New-VM -Name "WindowsCV5" -Version 5.0
, for example (from the above-cited article). I'm not sufficiently familiar with Packer to know how this "translates", and whether it's a simple configuration tweak, but it can't possibly be overly complicated.
I don't want to officially support anything but the latest versions as much as possible.
I don't blame you one bit! See my previous comment; this shouldn't change the support load for you.
Based on @vongrippen's comments, Looks like the only thing we'd lose is
Hibernation support | 9.0
Which would probably cause hard shutdowns for the VM when the system hibernates. Which in theory isn't the end of the world, and worst case should only be a vagrant destroy && vagrant up
away from fixing the issue.
I'm on configuration version 8.3 and I hibernate my machine every night when I leave the office, and it always pops right back up, VMs and all.
I think that Hyper-V either pauses the VMs or sends a shutdown to the VMs when going into hibernation on older versions, so it shouldn't be an issue at all.
I should be building beta version of base box v8 this weekend (soon™) and I'll make sure this gets added to settler before.
Awesome @svpernova09 .
Are we all in agreement that we can use configuration version 8.0 as a starting point?
If 8.0 causes any problems with Sleep or Hibernate, then I would propose using 8.3 instead, because it works fine with both, without sending a shutdown signal to the VM(s) (it appears to suspend the state).
8.3 is Windows 10 v1803, AKA Windows 10 April 2018 Update
, which any reasonable organization, even at the enterprise level, has embraced at this point.
Are we all in agreement that we can use configuration version 8.0 as a starting point?
Agreed, we should start with 8.0 and see what issues come up (if any). Glad we got this sorted out. Sorry it took so long to get here.
No problem! It's a complex issue that required some digging. It'll feel great to have this all ironed-out!
I should have a backwards compatible build for you later today, but it will be on the v8 branch for the base box, v9 branch for the Homestead repo itself. If you're interested in testing this out please create a new version of Homestead (don't upgrade your current dev system) in a separate folder. You'll want the latest version_9
branch of the Homestead repo. I'll update later today with a base box version to use.
ok, if everyone that's had issues with Hyper-V compatibility could test this out and give me some feedback that would be great.
Clone the version_9
branch of the Homestead repo. Add sites like you normally would. Add this to your Homestead.yaml
: box: v8.0.0-alpha3
And then run vagrant up
it should download the v8.0.0-alpha3
box. There is currently only a Hyper-V box for v8.0.0-alpha3
.
Giving this a try now, and for some reason, Vagrant doesn't "see" that box, even though it's clearly available at https://app.vagrantup.com/laravel/boxes/homestead/versions/8.0.0-alpha3 :
~\Work\Web\homestead-9 [version_9 ≡ +1 ~0 -0 !]> vagrant up
Bringing machine 'homesteadstock' up with 'hyperv' provider...
==> homesteadstock: Verifying Hyper-V is enabled...
==> homesteadstock: Verifying Hyper-V is accessible...
==> homesteadstock: Box 'v8.0.0-alpha3' could not be found. Attempting to find and install...
homesteadstock: Box Provider: hyperv
homesteadstock: Box Version: >= 8.0.0.pre.alpha2
==> homesteadstock: Box file was not detected as metadata. Adding it directly...
You specified a box version constraint with a direct box file
path. Box version constraints only work with boxes from Vagrant
Cloud or a custom box host. Please remove the version constraint
and try again.
Any idea what might be happening here?
I managed to get it working by deleting the Vagrantfile
and running the following commands:
vagrant init laravel/homestead https://app.vagrantup.com/laravel/boxes/homestead/versions/8.0.0-alpha3
vagrant up --provider=hyperv
Unfortunately, I still get this:
~\Work\Web\homestead-9 [version_9 ≡ +1 ~1 -0 !]> vagrant up --provider=hyperv
Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
==> default: Verifying Hyper-V is accessible...
==> default: Importing a Hyper-V instance
default: Creating and registering the VM...
An error occurred while executing a PowerShell script. This error
is shown below. Please read the error message and see if this is
a configuration error with your system. If it is not, then please
report a bug.
Script: import_vm.ps1
Error:
Failed to import a virtual machine.
Error Code: 32784
Cause: VM version is unsupported
Add box: v8.0.0-alpha3
to Homestead.yaml
and see if it pulls that version. Testing the box via vagrant init
will definitely cause unexpected things to happen since you're not booting the base box with the rest of Homestead.
I did add box: v8.0.0-alpha3
to Homestead.yaml
, per your instructions in https://github.com/laravel/homestead/issues/974#issuecomment-502159976 , prior to attempting the first time.
What's interesting about the error message in my first post re: this new box, is that it says:
You specified a box version constraint with a direct box file
path. Box version constraints only work with boxes from Vagrant
Cloud or a custom box host. Please remove the version constraint
and try again.
Out of curiosity, I tried commenting-out the version constraint specific in Homestead.rb
, and then it fails in this way:
~\Work\Web\homestead-9 [version_9 ≡ +1 ~0 -0 !]> vagrant up
Bringing machine 'homesteadstock' up with 'hyperv' provider...
==> homesteadstock: Verifying Hyper-V is enabled...
==> homesteadstock: Verifying Hyper-V is accessible...
==> homesteadstock: Box 'v8.0.0-alpha3' could not be found. Attempting to find and install...
homesteadstock: Box Provider: hyperv
homesteadstock: Box Version: >= 0
==> homesteadstock: Box file was not detected as metadata. Adding it directly...
==> homesteadstock: Adding box 'v8.0.0-alpha3' (v0) for provider: hyperv
homesteadstock: Downloading: v8.0.0-alpha3
homesteadstock:
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.
Couldn't open file /C:/Users/bjohnson/Work/Web/homestead-9/v8.0.0-alpha3
Vagrant seems to think that box: v8.0.0-alpha3
is a local file and not a version on Vagrant Cloud.
Ugh, I'm pretty bad at this. I forgot to click "Release" on the new version. I've done that now and now you should be able to use v8.0.0-alpha3
version box with the version_9
Repo branch
Confirmed via a different Windows 10 machine
PS C:\Windows\system32> vagrant box add laravel/homestead
==> box: Loading metadata for box 'laravel/homestead'
box: URL: https://vagrantcloud.com/laravel/homestead
==> box: Adding box 'laravel/homestead' (v8.0.0-alpha3) for provider: hyperv
box: Downloading: https://vagrantcloud.com/laravel/boxes/homestead/versions/8.0.0-alpha3/providers/hyperv.box
box: Download redirected to host: vagrantcloud-files-production.s3.amazonaws.com
Have been experiencing precisely the same problems as everyone else here. Unfortunately though it does seem as though v8.0.0-alpha3 is still not available. Confirmed this at app.vagrantup.com/laravel/boxes/homestead
PS C:\Users\tgreen\Homestead> vagrant up Bringing machine 'homestead' up with 'hyperv' provider... ==> homestead: Verifying Hyper-V is enabled... ==> homestead: Verifying Hyper-V is accessible... ==> homestead: Box 'v8.0.0-alpha3' could not be found. Attempting to find and install... homestead: Box Provider: hyperv homestead: Box Version: >= 8.0.0.pre.alpha2 ==> homestead: Box file was not detected as metadata. Adding it directly... You specified a box version constraint with a direct box file path. Box version constraints only work with boxes from Vagrant Cloud or a custom box host. Please remove the version constraint and try again.
@svpernova09 I'm able to reproduce what you pasted in https://github.com/laravel/homestead/issues/974#issuecomment-502470748 , but the box still does not work as we'd hoped.
~\Work\Web\homestead-9 [version_9 ≡ +1 ~0 -0 !]> vagrant box add laravel/homestead
==> box: Loading metadata for box 'laravel/homestead'
box: URL: https://vagrantcloud.com/laravel/homestead
==> box: Adding box 'laravel/homestead' (v8.0.0-alpha3) for provider: hyperv
box: Downloading: https://vagrantcloud.com/laravel/boxes/homestead/versions/8.0.0-alpha3/providers/hyperv.box
box: Download redirected to host: vagrantcloud-files-production.s3.amazonaws.com
box: Progress: 100% (Rate: 8862k/s, Estimated time remaining: --:--:--)
==> box: Successfully added box 'laravel/homestead' (v8.0.0-alpha3) for 'hyperv'!
~\Work\Web\homestead-9 [version_9 ≡ +1 ~0 -0 !]> vagrant up
Bringing machine 'homesteadstock' up with 'hyperv' provider...
==> homesteadstock: Verifying Hyper-V is enabled...
==> homesteadstock: Verifying Hyper-V is accessible...
==> homesteadstock: Importing a Hyper-V instance
homesteadstock: Creating and registering the VM...
An error occurred while executing a PowerShell script. This error
is shown below. Please read the error message and see if this is
a configuration error with your system. If it is not, then please
report a bug.
Script: import_vm.ps1
Error:
Failed to import a virtual machine.
Error Code: 32784
Cause: VM version is unsupported
Out of curiosity, and so I can perhaps help troubleshoot, what exactly did you change when baking the box, i.e., how did you pass -Version 8.0
in the Settler/Packer stage?
Edit to add:
Packer definitely has a switch for this: https://www.packer.io/docs/builders/hyperv-iso.html#configuration_version
Is this what you used?
Out of curiosity, and so I can perhaps help troubleshoot, what exactly did you change when baking the box, i.e., how did you pass -Version 8.0 in the Settler/Packer stage?
Edit to add:
Packer definitely has a switch for this: https://www.packer.io/docs/builders/hyperv-iso.html#configuration_version
Is this what you used?
Yeah that's exactly what I used. @vongrippen and I chatted and I'm betting there is something else I need to do to apply that configuration value. Will dig into it more this week. Would like to get this resolved before v9/v8 go Beta (which I'd like to get out asap)
Sounds good!
One easy way to ensure that "it worked" before bothering to upload the box is to provision it and then use Hyper-V Manager to inspect the configuration version:
Unless that says 8.0
, it's back to the drawing board. ;-)
One easy way to ensure that "it worked" before bothering to upload the box is to provision it and then use Hyper-V Manager to inspect the configuration version:
whoa now, let's not get too far ahead of ourselves with too much logic and reason! :D
Back to the drawing board >.>
This confirms my suspicion of needing to find how to APPLY that configuration value.
I can confirm what you're saying: adding "configuration_version": "8.0"
to the builders
object in bento\ubuntu\ubuntu-18.04-amd64.json
does not by itself make this value effective.
Maybe there's a clue in the directive's description:
configuration_version (string) - This allows you to set the vm version when calling New-VM to generate the vm. (emphasis mine)
Maybe we're not "calling New-VM to generate the vm". I wonder what that means, exactly...
I did a bit more digging and found a couple of relevant links:
Feature request that adds the ability to specify the Configuration Version:
https://github.com/hashicorp/packer/issues/5984
PR in which it's implemented:
https://github.com/hashicorp/packer/pull/7136
But I still can't find an example or figure out how one "calls New-VM to generate the vm"!
@cbj4074
@vongrippen found this: https://github.com/chef/bento/issues/1194 Which is likely the culprit. Once I get done with the Day Job today i'll see if I can build a version of packer locally to get around this bug.
@svpernova09 Well, that bug is a different issue from this. Though it only exists in newer versions of packer, which might be what is needed here for packer to actually use the configuration_version
setting. So it might need correcting for anyways.
I'm building a copy of the Hyper-V box right now with the latest version of packer as a test, fingers crossed.
Latest packer fixes the configuration_version
issue, but introduces another one where 2 config variables changed names for Hyper-V only (naturally). Can manually tweak those 2 variables to build for the moment, working on a PR with updated scripts to correct the issue (chef/bento#1194).
It's humorous that the issue was raised over two months ago, the OP submitted a PR that fixes it for 19.04 only, but nobody fixed it for 18.04 LTS, and the issue is still open... 😆
In any case, after I moved the configuration_version
directive to the variables
section and fixed those cpu
-> cpus
and ram_size
=> memory
issues in my local configuration, packer validate .\ubuntu-18.04-amd64.json
doesn't return any errors, but the VM is still created with configuration version 8.3
.
You're using Packer 1.4.1
@vongrippen ?
@cbj4074 I'm using packer 1.4.1, with configuration_version
inserted at line 244 within the hyperv-iso
builder. Putting it in variables below won't do anything for you because those are just variables for you to reference within your builder configurations.
My Hyper-V builder config that I'm testing with:
{
"boot_command": [
"<esc><wait10><esc><esc><enter><wait>",
"set gfxpayload=1024x768<enter>",
"linux /install/vmlinuz ",
"preseed/url=http://{{.HTTPIP}}:{{.HTTPPort}}/preseed-hyperv.cfg ",
"debian-installer=en_US.UTF-8 auto locale=en_US.UTF-8 kbd-chooser/method=us ",
"hostname={{.Name}} ",
"fb=false debconf/frontend=noninteractive ",
"keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ",
"keyboard-configuration/variant=USA console-setup/ask_detect=false <enter>",
"initrd /install/initrd.gz<enter>",
"boot<enter>"
],
"boot_wait": "10s",
"communicator": "ssh",
"cpu": "{{ user `cpus` }}",
"disk_size": "{{user `disk_size`}}",
"enable_secure_boot": false,
"generation": "{{user `hyperv_generation`}}",
"configuration_version": "8.0",
"http_directory": "http",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"iso_url": "{{user `mirror`}}/{{user `mirror_directory`}}/{{user `iso_name`}}",
"output_directory": "../builds/packer-{{user `template`}}-hyperv",
"ram_size": "{{user `memory`}}",
"shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now",
"ssh_password": "vagrant",
"ssh_port": 22,
"ssh_timeout": "10000s",
"ssh_username": "vagrant",
"switch_name": "{{user `hyperv_switch`}}",
"type": "hyperv-iso",
"vm_name": "{{ user `template` }}"
}
Aha! Thanks for setting me straight with regard to where configuration_version
needs to be inserted. I suppose I did have it in the correct location earlier, but my Packer version wasn't new enough to support it, so validation failed. Makes sense now!
Now we're cookin'! 🤞
Looking good so far
Mine completed successfully! 👏
Now to provision with it and let it "cook"... in particular, I'll test the sleep/hibernate behavior and report my findings.
Awesome. ONce my provision finishes and I verify the box output comes in as Version 8, I'll upload and tag a new beta box
I've got the box built locally, and added to Vagrant, spun up new Homestead and Hyper-V Manager is reporting 8.2 Not sure why we go from 8.0 -> 8.2 but this should work for our 1803 users.
https://app.vagrantup.com/laravel/boxes/homestead/versions/8.0.0-alpha4
Warning: Looks like PHP 7.3 is missing from this box, not sure why.
Interesting, re: the configuration version changing from 8.0
while packing to 8.2
after booting.
I just spun-up a new box with the image I packed locally and the version remains at 8.0
. So, we should look into that... It's true that 8.2 should work for anyone on Windows build 1803, but my concern is more that it's "behaving as we expect" and we won't be surprised down the road.
Also, PHP 7.3 is installed and set as the default in the box I just packed... are you sure you're actually using the box you think you are?
I'll try grabbing the one from your previous post and see what happens for me...
I built it on the version_8 branch of settler. I've been mostly distracted by the day job today. about to wrap that up for the day and dive into this
So, I still can't use these Alpha boxes without adding the box manually first, e.g.:
~\Work\Web\homestead-9 [version_9 ≡ +1 ~0 -0 !]> vagrant box add laravel/homestead
==> box: Loading metadata for box 'laravel/homestead'
box: URL: https://vagrantcloud.com/laravel/homestead
==> box: Adding box 'laravel/homestead' (v8.0.0-alpha4) for provider: hyperv
box: Downloading: https://vagrantcloud.com/laravel/boxes/homestead/versions/8.0.0-alpha4/providers/hyperv.box
box: Download redirected to host: vagrantcloud-files-production.s3.amazonaws.com
box: Progress: 100% (Rate: 5839k/s, Estimated time remaining: --:--:--)
==> box: Successfully added box 'laravel/homestead' (v8.0.0-alpha4) for 'hyperv'!
But then it still fails, presumably due to the version constraint:
~\Work\Web\homestead-9 [version_9 ≡ +1 ~0 -0 !]> vagrant up
Bringing machine 'homesteadstock' up with 'hyperv' provider...
==> homesteadstock: Verifying Hyper-V is enabled...
==> homesteadstock: Verifying Hyper-V is accessible...
==> homesteadstock: Box 'v8.0.0-alpha4' could not be found. Attempting to find and install...
homesteadstock: Box Provider: hyperv
homesteadstock: Box Version: >= 8.0.0.pre.alpha2
==> homesteadstock: Box file was not detected as metadata. Adding it directly...
You specified a box version constraint with a direct box file
path. Box version constraints only work with boxes from Vagrant
Cloud or a custom box host. Please remove the version constraint
and try again.
So I remove (comment-out) the version constraint in Homestead.rb
, and then get this:
~\Work\Web\homestead-9 [version_9 ≡ +1 ~0 -0 !]> vagrant up
Bringing machine 'homesteadstock' up with 'hyperv' provider...
==> homesteadstock: Verifying Hyper-V is enabled...
==> homesteadstock: Verifying Hyper-V is accessible...
==> homesteadstock: Box 'v8.0.0-alpha4' could not be found. Attempting to find and install...
homesteadstock: Box Provider: hyperv
homesteadstock: Box Version: >= 0
==> homesteadstock: Box file was not detected as metadata. Adding it directly...
==> homesteadstock: Adding box 'v8.0.0-alpha4' (v0) for provider: hyperv
homesteadstock: Downloading: v8.0.0-alpha4
homesteadstock:
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.
Couldn't open file /C:/Users/bjohnson/Work/Web/homestead-9/v8.0.0-alpha4
As long as you're on Homestead version_9
branch you should be able to run vagrant box update
and it'll reach out and grab the latest version:
PS C:\users\halo\Code\homestead> vagrant box update
==> homestead: Checking for updates to 'laravel/homestead'
homestead: Latest installed version: 8.0.0-alpha3
homestead: Version constraints:
homestead: Provider: hyperv
==> homestead: Updating 'laravel/homestead' with provider 'hyperv' from version
==> homestead: '8.0.0-alpha3' to '8.0.0-alpha4'...
==> homestead: Loading metadata for box 'https://vagrantcloud.com/laravel/homestead?access_token=pPxaV3VGRDshjA.atlasv1.8sQMWGwfMOqh8zeyF6TI9gH88SDXzC9LliShzHyK6GNCIxxvyEcNVClfySCLMqNd6V0'
==> homestead: Adding box 'laravel/homestead' (v8.0.0-alpha4) for provider: hyperv
homestead: Downloading: https://vagrantcloud.com/laravel/boxes/homestead/versions/8.0.0-alpha4/providers/hyperv.box
Ahh! The problem is that I still had box: v8.0.0-alpha4
hard-coded in Homestead.yaml
. Removing that fixed it. 👍 Thanks!
And yep, that box works on my machine now, so that's progress!
The only other thought I have once you dive into this tonight is that packer validate .\ubuntu-18.04-amd64.json
generates warnings about the CPU and memory configuration until I remove the following lines from the file:
"memsize": "{{ user `memory` }}",
"numvcpus": "{{ user `cpus` }}"
"cpu": "{{ user `cpus` }}",
"ram_size": "{{user `memory`}}",
The warning is:
Warnings for build 'vmware-iso':
* Your vmx data contains the following variable(s), which Packer normally sets when it generates its own default vmx template. This may cause your build to fail or behave unpredictably: numvcpus, memsize
If you submit a PR to fix this, @vongrippen , maybe it makes sense simply to remove these in your PR.
While I can't speak for other Bento users, in our specific case, the values in Homestead.yaml
override these, when specified, so I don't see any obvious downside to removing them.
@cbj4074 Actually already accounted for the Hyper-V config validation in the PR I opened on laravel/settler for building the boxes 😉
laravel/settler#204
I think we're clear to close this now right @cbj4074?
Yep!
I've been running that v8.0.0-alpha4
box for a couple days now, and have Hibernated and Slept several times, and haven't noticed any issues upon waking the machine. So, we should be okay with config version 8.0
!
Great news!
--
I've been running that v8.0.0-alpha4 box for a couple days now, and have Hibernated and Slept several times, and haven't noticed any issues upon waking the machine. So, we should be okay with config version 8.0! — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
Versions
Host operating system
Windows 10 Enterprise Version 1803, build 17134.286.
Homestead.yaml
Vagrant destroy & up output
https://gist.github.com/cbj4074/01317421b6ce2bf9ea8c610f76ffbecc
Expected behavior
Provisioning should succeed.
I should note that provisioning with Hyper-V succeeds when using https://app.vagrantup.com/generic/boxes/ubuntu1804/versions/1.8.40 , for example, so the issue seems to be box-specific.
Actual behavior
Provisioning fails almost immediately, when creating and registering the VM.
This seems to be related, at least in part, to the issues cited under References.
However, it seems that some/most/all of these individuals have the opposite problem (as described in the comment https://github.com/hashicorp/vagrant/issues/9317#issuecomment-437025611 ), whereby the box specifies a Hyper-V VMHost version that is greater than what the host OS supports. This seems to be a different issue, because the output on my machine reports version 8.3:
The second issue cited below implies that there's a means by which to "validate the host is able to support the [Hyper-V] version". Might anyone know which value would be checked? I'd like to check it manually in the meantime.
Steps to reproduce
References