XenDesktop 5 – The provisioning task is already running on the catalog Error
James Denne, Citrix, has published a nice article about error “The provisioning task is already running on the catalog” that you can receive when you add a small number of machines to a XenDesktop catalog.
What is a Provisioning Task?
When an administrator decides to use Machine Creation Services to create virtual desktops, Desktop Studio will create a ”provisioning task” which is an administrative reference and a group of settings for the work being done to clone virtual machines from the master image. You can see an example of how Provisioning Tasks are used to create catalogs here and the PowerShell commands are documented here.
Finding the running task
A desktop catalog can only have a single provisioning task running at a time, and although Desktop Studio did not show any tasks in progress, when you try to add more virtual desktops to the catalog you see an error indicating exactly that.
So Desktop Studio could not help us here; we could not see any running tasks. Therefore we had to drop to the command line and use PowerShell to understand the problem, and then to resolve it.
The first command we ran is:
Get-ProvTask
The output of this command is a full list of all the tasks that have been run by Machine Creation Services: about 70 in total. Each task output looks something like this (some information anonymised):
TaskId : 4da36947-2d25-4213-860a-35bf37207d00
Active : False
Host : XD5DDC1
DateStarted : 04/01/2012 14:41:09
Type : NewVirtualMachine
Metadata : {Citrix_DesktopStudio_DesktopCatalogId = 13, Citrix_DesktopStudio_StartTime = 6346
12848661173317, Citrix_DesktopStudio_TaskGroupId = b3670ee2-2fa9-4814-acb1-04f5f70
858b0, Citrix_DesktopStudio_TimeTaken = 754970396}
WorkflowStatus : Completed
MasterImage : XDHyp:\HostingUnits\XENDESKTOP\win764GOLD.vm\Citrix_XD_Win7 64 Bit.snapshot\Citri
x_XD_Win 7 64 Bit.snapshot\Citrix_XD_Windows 7 64.snapshot\Citrix_XD_Windows 7 64.
snapshot
ProvisioningSchemeName : Windows 7 Desktop
ProvisioningSchemeUid : 76b65abd-ed08-4e0f-91ef-397e6d9dbe83
TaskState : Finished
TaskStateInformation :
HostingUnitUid : 45142a5f-7828-4be7-a223-0693934d5905
HostingUnitName : XD5
IdentityPoolUid : 2950cdb0-423a-4044-814c-a99cdc97afe1
IdentityPoolName : Windows 7
VirtualMachinesToCreateCount : 1
VirtualMachinesCreatedCount : 1
VirtualMachinesCreationFailedCount : 0
CreatedVirtualMachines : {VDI-0000123}
FailedVirtualMachines : {}
ProvisioningJob : dcc8c19a-a5b6-46d6-9d4b-63cbb8c51333
ProvisioningStatus : Completed
Immediately the “Task State” property looks interesting. On the list of the tasks you can see a task that had been running for over a week:
TaskId : 3071f618-c786-444e-bf3b-8a1e7b05baf5
Active : True
Host : XD5DDC1
DateStarted : 29/12/2011 11:35:06
Type : RemoveVirtualMachine
Metadata : {Citrix_DesktopStudio_TaskGroupId = 6175c94a-e068-49e0-aba8-e39503230c55}
WorkflowStatus : Running
ProvisioningSchemeUid : 5dd053a0-4dad-4618-a497-f04ea8e4228c
ProvisioningSchemeName : Windows 7 Desktop
TaskState : Removing
TaskStateInformation :
VirtualMachinesToRemoveCount : 6
RemovedVirtualMachines : {VDI-0000119, VDI-0000111, VDI-0000120, VDI-0000123...}
FailedVirtualMachines : {}
VirtualMachinesRemovedCount : 6
VirtualMachinesFailedCount : 0
ProgressEstimator : 5
What we see here is a Provisioning Task that is removing 6 desktops from a catalog. In fact if we compare the “VirtualMachinesToRemoveCount” with the “VirtualMachinesRemovedCount” both settings have a value of 6. This suggests that this task to remove 6 virtual machines had in fact completed, but the task had become stuck or timed out or had not been marked as completed in the database.
Stopping the Task
Because the task shows as completed (all virtual machines had been removed) and because 8 days had elapsed since the task was started, we decides it would be safe to manually stop this task with the following command:
Stop-ProvTask –TaskId 3071f618-c786-444e-bf3b-8a1e7b05baf5 –AdminAddress <your controller address>
(I should caution you not to stop tasks that have not completed. Some tasks will create or delete accounts from Active Directory, and if you manually stop the task you may leave accounts in place when in fact you want them deleted. If you are unsure how to proceed please contact Citrix Technical Support.)
We run get-provtask again and we can see that this task is now stopped. We can see another task running with the details shown below, but this task should NOT be stopped. It is an admin task that cleans up unused Master Images:
TaskId : 00de4ac5-1bff-43ca-ba0d-86f638fe9fed
Active : True
Host : XD5DDC1
DateStarted : 15/08/2011 16:35:20
Type : DisusedImageCleanUp
Metadata : {}
WorkflowStatus : Running
PendingDeletes : 1
Did this fix it?
Not quite. Desktop Studio would still not allow the customer to create more VMs, again showing an error indicating that a Provisioning Task is running.
Provisioning Schemes
As well as Provisioning Tasks which are the “units of work” for Machine Creation Services, there are also items called “Provisioning Schemes”. A Provisioning Scheme is the collection of settings that will be applied to the virtual desktops created under the scheme. You can view your provisioning schemes by running the following command:
get-provscheme
Run the command and see the following output:
ProvisioningSchemeUid : 5dd053a0-4dad-4618-a497-f04ea8e4228c
ProvisioningSchemeName : Windows 7 Desktop
CpuCount : 1
MemoryMB : 4096
DiskSize : 30
MasterImageVM : XDHyp:\HostingUnits\XENDESKTOP\IT6MCSGOLD.vm\Citrix_XD_IT6 Catalog.snapshot
MasterImageVMDate : 17/08/2011 12:18:39
IdentityPoolUid : a71ad46d-bfbc-4f5f-bd22-21d2f5b8872f
IdentityPoolName : Windows 7
HostingUnitUid : 45142a5f-7828-4be7-a223-0693934d5905
HostingUnitName : XD5
CleanOnBoot : False
TaskId : 3071f618-c786-444e-bf3b-8a1e7b05baf5
Metadata : {}
MachineCount : 73
ControllerAddress : {XD5DDC1.domain.local, XD5DDC2.domain.local}
VMMetadata : {H, 4, s, I...}
If you look at the TaskId field we see a reference to the task we manully stopped. This lingering reference means the provisioning scheme is locked so we cannot initiate any more tasks under this scheme.
To clear this reference we ran the following PowerShell:
Unlock-ProvScheme -ProvisioningSchemeUid "5dd053a0-4dad-4618-a497-f04ea8e4228c”
This unlocks the provisioning scheme and allows you to create virtual machines again. The following PowerShell commands are used to fix this issue, with their documentation links:
Get-ProvTask - http://support.citrix.com/static/kc/CTX127254/help/Get-ProvTask.htm
Stop-ProvTask - http://support.citrix.com/static/kc/CTX127254/help/Stop-ProvTask.htm
Get-ProvScheme - http://support.citrix.com/static/kc/CTX127254/help/Get-ProvScheme.htm
Unlock-ProvScheme - http://support.citrix.com/static/kc/CTX127254/help/Unlock-Pro
