Symptoms:
Cannot create snapshot
Operation not allowed in current state
/var/run/log/hostd.log:
YYYY-MM-DDThh:mm:ss.111Z error hostd[2100433] [Originator@#### sub=Vmsvc.vm:/vmfs/volumes/<datastore_id>/<vm_name>/vm_name.vmx opID=esxui-####-#### user=root] Invalid transition requested (VM_STATE_EXPORTING -> VM_STATE_CONSOLIDATE_ALL_DISKS): Invalid state
vSphere 7.x, 8.x
This error occurs if the VM is currently undergoing a change in sate as there are related tasks running or queued up for that vm.
To resolve this issue, ideally the task(s) need to be allowed some time to continue to proceed with success or time out automatically.
In case the task needs to be cancelled, kindly proceed with caution being thoughtful of the environment and the impact on the same. There are certain tasks like storage vmotion or snapshot deletion/ consolidation tasks which are not recommended to be cancelled due to risk of data loss. If you are unsure, please raise a ticket with Broadcom Support
To cancel the task(s) following steps need to be attempted:
vim-cmd vmsvc/getallvms |grep <vm_name>
vim-cmd vmsvc/get.tasklist <vm_id>
Example output:
(ManagedObjectReference) [
'vim.Task:haTask-<vm_id>-vim.VirtualMachine.<task_name>-####'
]
vim-cmd vimsvc/task_info “<task_string>”
Example:
vim-cmd vimsvc/task_info haTask-<vm_id>-vim.VirtualMachine.
<task_name>
-####
Example Output:
(vim.TaskInfo) {
dynamicType = ,
key = "haTask-<vm_id>-vim.VirtualMachine.
<task_name>
-####",task = 'vim.Task:haTask-<vm_id>-vim.VirtualMachine.
<task_name>
-####',description = (vmodl.LocalizableMessage) null,
name = "vim.VirtualMachine.
<task_name>
",descriptionId = "VirtualMachine.
<task_name>
", entity = 'vim.VirtualMachine:<vm_id>',
entityName = "<vm_name>",
state = "running",
cancelled = false,
cancelable = false,
error = (vmodl.MethodFault) null,
result = ,
progress = <progress%>,
reason = (vim.TaskReasonUser) {
dynamicType = ,
userName = "<user_name>",
},
queueTime = "YYYY-MM-DDThh:mm:ss.224526Z",
startTime = "YYYY-MM-DDThh:mm:ss.225526Z",
completeTime = ,
eventChainId = ####,
changeTag = ,
parentTaskKey = ,
rootTaskKey = ,
}
vim-cmd vimsvc/task_cancel “<task_string>”
Example:
vim-cmd vimsvc/task_cancel “<haTask-<vm_id>-vim.VirtualMachine.<task_name>-####>”