When attempting to provision virtual machines using Terraform within a vCenter Server environment, the deployment fails with the following error:
error running VM migration: error running vMotion on datastore cluster <datastore_cluster_name>: There are no active hosts in the cluster.
This issue occurs when attempting to deploy VM templates that contain hardcoded CPU feature masks that are incompatible with the target cluster's Enhanced vMotion Compatibility (EVC) baseline. This causes the DRS placement engine to fail its compatibility evaluation for all candidate hosts in the cluster.
VMware vCenter Server 8.0
The error occurs during the automated DRS placement compatibility check. DRS evaluates candidate hosts in the target cluster against the CPU features required by the VM template.
If the VM template contains hardcoded CPU feature masks (i.e., featMask.vm.cpuid parameters) that are not supported by the cluster's current EVC baseline, the compatibility evaluation fails for all hosts in the cluster. Because no compatible hosts are identified, the SDRS engine returns the error: "There are no active hosts in the cluster."
This behavior is enforced by DRS placement logic, even if the VM might successfully power on when manually placed on a single host.
Resolution
The permanent resolution is to modify the VM template to remove the hardcoded CPU feature masks, aligning the template configuration with the target cluster's EVC baseline.
1. Identify the VM template being utilized for the Terraform deployment.
2. Convert the template to a virtual machine.
3. Edit the virtual machine settings or the .vmx configuration to remove restrictive CPU feature masks.
4. Ensure that featureCompat.vm.completeMasks is set correctly for the environment.
5. Convert the virtual machine back to a template.
6. Retry the Terraform deployment.
Workaround
If an immediate deployment is required while the template is being remediated, you may temporarily disable DRS on the target cluster to bypass the DRS compatibility check.
Note: This is a temporary measure and is not recommended as a long-term configuration.
1. Navigate to the target Cluster in the vSphere Client.
2. Select the Configure tab.
3. Under Services, select vSphere DRS.
4. Click Edit.
5. Uncheck vSphere DRS to disable it.
6. Click OK.
7. Perform the VM deployment via Terraform.
8. Once the deployment is successful, re-enable vSphere DRS on the cluster by reversing the steps above.