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

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

book

Article ID: CTX138318

calendar_today

Updated On:

Description

When attempting to delete hosting infrastructure (either a Connection or Resources) from Citrix Studio, the following message appears:

"Resources "Local storage" cannot be deleted because they are being used by the following Machine Catalogs and/or background actions:..."

User-added image

Background

To avoid overloading the hypervisor, Machine Creation Services (MCS) delays the deletion of unused disks from a Catalog in some scenarios. To complete this deletion process, MCS requires the Resources that were used to create the Catalog are not deleted until all the unused disks are deleted.

The preceding message appears if attempting to delete the Resources used to create the Catalog (or the Connection that owns the Resources) when MCS is yet to delete the unused disk.

Environment

The above mentioned sample code is provided to you as is with no representations, warranties or conditions of any kind. You may use, modify and distribute it at your own risk. CITRIX DISCLAIMS ALL WARRANTIES WHATSOEVER, EXPRESS, IMPLIED, WRITTEN, ORAL OR STATUTORY, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT. Without limiting the generality of the foregoing, you acknowledge and agree that (a) the sample code may exhibit errors, design flaws or other problems, possibly resulting in loss of data or damage to property; (b) it may not be possible to make the sample code fully functional; and (c) Citrix may, without notice or liability to you, cease to make available the current version and/or any future versions of the sample code. In no event should the code be used to support ultra-hazardous activities, including but not limited to life support or blasting activities. NEITHER CITRIX NOR ITS AFFILIATES OR AGENTS WILL BE LIABLE, UNDER BREACH OF CONTRACT OR ANY OTHER THEORY OF LIABILITY, FOR ANY DAMAGES WHATSOEVER ARISING FROM USE OF THE SAMPLE CODE, INCLUDING WITHOUT LIMITATION DIRECT, SPECIAL, INCIDENTAL, PUNITIVE, CONSEQUENTIAL OR OTHER DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Although the copyright in the code belongs to Citrix, any distribution of the sample code should include only your own standard copyright attribution, and not that of Citrix. You agree to indemnify and defend Citrix against any and all claims arising from your use, modification or distribution of the sample code.

Resolution

To resolve this issue, complete the following steps:

Note: Ensure that all Catalogs still use the Resources that are deleted using the Catalogs node in Studio.

  1. To obtain a precise estimate of when the disks will be deleted, run the following PowerShell commands on any Controller in the Site:

    Add-PsSnapin Citrix.Host.Admin.V2

    Add-PsSnapin Citrix.MachineCreation.Admin.V2

    Cd XDHyp:\HostingUnits

    Get-ChildItem

    Running the preceding commands returns a list of Resources (called “HostingUnits” in the SDK), and will look similar to the following:

    User-added image

  1. From this step, note HostingUnitUid of the Resources that you are trying to delete (highlighted in the preceding screenshot) and then run the following command, substituting HostingUnitUid from your environment:

    Get-ProvTask | Where-Object { $_.ImagesToDelete | Where-Object { $_.HostingUnit -eq "a3284d3e-848c-4f98-ad74-61457b990a7f" } }

    Running the preceding command gives a list of tasks that still need to complete before the Resources can be deleted, and will look similar to the following:

    User-added image

    From the preceding screenshot, it is noticed that the last attempt which was made to delete the disks is in the LastUpdateTime field, and the next attempt that will be made is in the RetryInterval field (specified in hours:minutes: seconds). In this case, the next attempt is made at 10/10/2013 2:48:82 PM.

    To remove this task execute command Remove-ProvTask-TaskID  <EnterTaskID>

    If no tasks are listed then all tasks have already been completed. Attempt to remove storage with the following commands:
    Storage : 
    Remove-HypHostingUnitStorage -LiteralPath XDHyp:\HostingUnits\MyHostingUnit -StoragePath 'XDHyp:\HostingUnits\MyHostingUnits\newStorage.storage'

    PersonalvDiskStorage:

    Get-ChildItem XDHyp:\HostingUnits\MyHostingUnit\*.storage | Remove-HypHostingUnitStorage -LiteralPath XDHyp:\HostingUnits\MyHostingUnit -StorageType PersonalvDiskStorage

    TemporaryStorage:
    Get-ChildItem XDHyp:\HostingUnits\MyHostingUnit\*.storage | Remove-HypHostingUnitStorage -LiteralPath XDHyp:\HostingUnits\MyHostingUnit -StorageType TemporaryStorage

    Hosting Resource Name
    Remove-Item -path XDHyp:\HostingUnits\MyHostingUnit

     

Issue/Introduction

This article provides a resolution to the issue - Unable to delete Resources: There is currently an active background action.

Additional Information

 https://docs.citrix.com/de-de/xenapp-and-xendesktop/7-1/cds-reference-wrapper-rho/cds-sdk-wrapper-rho/cds-sdk-cmdlet-help/citrix-host-admin-v2-wrapper-xd71/remove-hyphostingunitstorage-xd71.html
https://support.citrix.com/article/CTX131207