Getting "Datastore Faults: This operation would violate a virtual machine affinity/anti-affinity rule" when trying to add a new Hard Disk to the Virtual Machine
search cancel

Getting "Datastore Faults: This operation would violate a virtual machine affinity/anti-affinity rule" when trying to add a new Hard Disk to the Virtual Machine

book

Article ID: 411677

calendar_today

Updated On:

Products

VMware vCenter Server

Issue/Introduction

  • Adding a new Hard Disk to an existing Virtual Machine fails with error "This operation would violate a virtual machine affinity/anti-affinity rule". Below is how it looks like in the vSphere UI.


  • This specifically happens when a user tries to place the disk on a different Datastore than the one where the original disks are placed. The same can be done by selecting a different datastore under "Edit Settings > Add New Device > Hard Disk" and then specifying a new Datastore under "Location" rather than keeping the default option "Store with the virtual Machine". 

  • The cluster is configured to user Storage DRS in Fully Automated mode.

  • No affinity or anti-affinity rule of any kind, be it on the compute or storage DRS configuration has been set for the affected VM.

Environment

VMware vCenter Server 7.x
VMware vCenter Server 8.x

Cause

The Default VM affinity rule of the Storage DRS keeps the VMDKs' of the Virtual Machine together. The same can be confirmed by navigating to the Datastore Cluster object > Configure > Storage DRS (under services) > Advanced options. Below is how the default setting looks like.

As a result, it won't allow a user to place the virtual disks separately unless configured otherwise.

Resolution

  • Under the Datastore cluster, navigate to Configure > Storage DRS.
  • Click on Edit to modify the "Advanced options" for Storage DRS.
  • Toggle off the VM affinity option "Keep VMDKs together by default" and save the modification.

Please note that any changes to the storage DRS config might trigger a generation as well as an execution of the storage DRS recommendations which leads to the movement of Virtual Machines across datastores. As a result, the virtual machines might experience a considerable stun depending on how IO intensive the storage vMotion turns out to be.