Jump to content
Welcome to our new Citrix community!
  • 0

Unable to Delete Resources: There is currently an active background action


Jason Moran1709154312

Question

Hello

 

After reading and performing the steps in CTX138318, I have encountered a very large number of tasks that need to have the commands Stop-ProvTask -TaskID "Put-Here-Your-Task-ID" and Remove-ProvTask -TaskID "Put-Here-Your-Task-ID" run against them.

 

I am still learning powershell, can anyone help me with automate this process with the commands Get-ProvTask | Where-Object {$_.ImagestoDelete | Where-Object { $_.HostingUnit -eq "Put-Here-Your-Hosting-ID"}} along with the 2 previously mentions commands?

 

Jason

Link to comment

11 answers to this question

Recommended Posts

  • 4

Do you have any Catalogs using the Connection still? If so delete these and try removing the tasks again before proceeding...

 

After deleting any catalog that could be using the connection you may need to just resort to PowerShell to remove the connections (Perhaps MCS or Studio has gotten mixed up with background task due to not being able to use the connection anymore).

 

Add-PSSnapin Citrix.Broker.Admin.V2

Add-PSSnapin Citrix.Host.Admin.V2

Remove-Item -path "xdhyp:\HostingUnits\[HostingUnitName]"

Remove-BrokerHypervisorConnection -Name "[ConnectionName]"

Remove-Item -path  "xdhyp:\Connections\[ConnectionName]"

 

If you refresh the nodes in studio (or just restart studio) the connection should be removed.

  • Like 8
Link to comment
  • 1

Ok, I'd attempt a more brute force approach then. The following commands will remove all the tasks that used to belong to the hosting unit (resource) that you wish to delete (I don't think it's a question of limiting them to particular images).

 

  • Add-PSSnapin Citrix.MachineCreation.Admin.V2
  • Get-ProvTask | Where-Object { $_.HostingUnit -eq "Put-Here-Your-Hosting-ID"} | Stop-ProvTask 
  • Get-ProvTask | Where-Object { $_.HostingUnit -eq "Put-Here-Your-Hosting-ID"} | Remove-ProvTask 

 

you can retrieve the hosting unit id by calling Get

  • Add-PSSnapin Citrix.Host.Admin.V2
  • cd xdhyp:\HostingUnits\
  • dir

(the hosting unit to find the id of will have the same name that you gave the hosting resource in studio - they are the same thing)

 

After running the commands above you should be able to remove the connection from Studio.

 

Note: If you associated more than one Resource with the connection that you wish to delete then you'll have to run the commands above for each Hosting Unit (Resource)

  • Like 1
Link to comment
  • 0

Hi,

What is it that you are trying to achieve with the command? MCS does run background disk cleanup tasks occasionally. I wouldn't advise just removing these tasks just to delete a host resource. If you remove the tasks then those disk images will not be cleared from your storage - is this your intention?

 

Have you monitored the backgrounds tasks at all? What are their current states?

 

Terry

Link to comment
  • 0

Hey Terry

 

We have migrated to a new ESXi Environment (in place VMware Upgrade), I have one host connection that pertains to the to the hosts as they were in before the upgrade. The intention is to remove the original Host Connection but I am unable due to Background Tasks that seem to be stuck. The upgrade was not the cause as the start dates for these tasks are from before the upgrade.

 

The background task states are all in running Status. I have not monitored them before as XD 7.1 does not have a facility to do so unless its done via powershell that I can see and as I am not very fluent in Powershell.

 

Jason

Link to comment
  • 0

Hey Terry

 

I have Stopped and Removed the Tasks for all of the hosting units now. I had to use the short little powershell script (a coworker helped) as there was a large number of them associated with one Hosting Unit. Having said that I am still unable to delete the old Host Connection and its Resources. The error received is as follows:

 

Connections "HostConnectionName" cannot be deleted because it is being used by the following, Machine Catalogs, and/or background actions:
There are 9 active background actions
Please try again later. Learn more

 

The Get-ProvTask commands for the HostingUnits returns no tasks.

 

I ran Tests on the Host Connection and its resources and found that there were a number of errors related to the Resources of the host connection as show below.

 

Controller SERVERNAME: The storage with ID /DATACENTER/CLUSTER/STORAGE could not be found. Current Node not found. id = `datastore-1688`, type = `storage`.
Ensure that the storage exists, or use different storage.

 

This error makes sense to me as the Hosts (VMware) were all upgraded from VMware 5.1 to 5.5. This is believe is unrelated to all of the Provisioning Tasks as many of them have gone back several months. The VMware upgrade from 5.1 to 5.5 was recent.

 

Jason

Link to comment
  • 0

i did:

 

asnp Citrix*

Get-ProvTask | where {$_.Type -eq “DisusedImageCleanup” -and $_.Status -ne “Finished”} | Stop-ProvTask

Get-ProvTask | where {$_.Type -eq “DisusedImageCleanup” -and $_.WorkflowStatus -ne “Active”} | Remove-ProvTask

Remove-Item -path "xdhyp:\HostingUnits\[HostingUnitName]"

Remove-BrokerHypervisorConnection -Name "[ConnectionName]"

Remove-Item -path  "xdhyp:\Connections\[ConnectionName]"

 

All together by powerhshell. If i remove the tasks first and try to remove the hosting connection by GUI, there are new tasks created in the meantime. So if i do all the stuff in one flow by powershell, the new tasks get not created and i can delete the hosting connection.

Link to comment
  • 0

Same issue, but after cleanup of active tasks I still can't delete the resources/connection via Studio.

 

"get-provtask" returns no more tasks after cleanup for the specific hostingunit and when trying to delete the resources we get:

 
There are 2 active background actions
Please try again later. 
 

Any clues?

***Update***

Had to use powershell to delete connection/resources to the no longer existing VMWare environment.
https://support.citrix.com/article/CTX207224

 

Edited by osterck379
Found solution
Link to comment
  • 0
On 11/18/2014 at 11:41 PM, Terry Highfield said:

Do you have any Catalogs using the Connection still? If so delete these and try removing the tasks again before proceeding...

 

After deleting any catalog that could be using the connection you may need to just resort to PowerShell to remove the connections (Perhaps MCS or Studio has gotten mixed up with background task due to not being able to use the connection anymore).

 

Add-PSSnapin Citrix.Broker.Admin.V2

Add-PSSnapin Citrix.Host.Admin.V2

Remove-Item -path "xdhyp:\HostingUnits\[HostingUnitName]"

Remove-BrokerHypervisorConnection -Name "[ConnectionName]"

Remove-Item -path  "xdhyp:\Connections\[ConnectionName]"

 

If you refresh the nodes in studio (or just restart studio) the connection should be removed.

 

Thanks Terry, this perfectly worked for me as well.

 

Regards,

Quaseem Siddiqi

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...