Permanently remove deleted resource from JBoss ON inventory

Solution Unverified - Updated

Environment

  • Red Hat JBoss Operations Network (ON) 3.3
  • The DELETE inventory operation has been used on a resource

Issue

  • After delete of resource its data, history, and content remains in the database
  • How to permanently remove deleted resources from inventory

Resolution

Beginning with JBoss ON 3.3 Update-08 (3.3.8) the JBoss ON Command-Line Interface (CLI) script uninventory_deleted.js is included in the misc/uninventory-deleted directory of the update archive. This script can be executed to find and permanently remove and uninventory specific resources that are in a DELETED state.

WARNING: Once a resource has been removed, its history and all related content, including its child resources and their history will be lost. The only way to undo the process is restore the entire JBoss ON database from a backup.

Execute the uninventory_deleted.js CLI script passing it the uninventory argument followed by a space delimited list of resource ids that should be permanently removed or deleted.

rhq-cli.sh -u myusername -p mypassword -s jboss-on.example.com -t 7080 -f uninventory_deleted.js uninventory <ID1> <ID2>

For details on using the uninventory_deleted utility, see 2906141: Using uninventory_deleted JBoss ON CLI script to permanently remove deleted resources from inventory. Usage information is also available by passing help to the uninventory_deleted.js script.

Root Cause

Some resource types in JBoss ON inventory support the DELETE operation. The DELETE operation will typically remove the physical deployment or component from its parent resource and mark the resource's inventory status as DELETED. For example, if you have a WAR deployed to a JBoss EAP 6 standalone server and invoke the JBoss ON DELETE operation on it, the JBoss EAP management plug-in will submit an undeploy request to the target JBoss EAP server for the selected resource. Additionally, the resource in JBoss ON inventory is marked with an inventory status of DELETED. This means the resource will no longer appear in the inventory pages of the JBoss ON user-interface (UI) and management and monitoring operations will no longer be performed on the deleted resource. However, the resource will remain hidden in inventory. In cases of redeployment, the existing histories and related data from the previously deleted resource is restored along with the normal management and monitoring operations for the redeployed resource.

In some cases, it may no longer be necessary for the resource and its related history and content to remain in inventory. For example, in a development environment you may deploy various artifacts, using different names or types, several times during testing. When you remove the various deployments using the DELETE inventory operation, you may want them to be permanently removed so that their associated content is deleted from the back-end data store and space can be reclaimed.

Because a resource with the DELETED inventory status is no longer available in the UI, you can't perform the uninventory operation which is necessary to permanently remove the previously deleted resource.

Diagnostic Steps

  • The JBoss ON CLI can be used to see if there are any resources in a deleted state.

      ./rhq-remoting-cli/bin/rhq-cli.sh -u rhqadmin -p rhqadmin -s localhost -t 7080 -c 'var rc = new ResourceCriteria(); rc.setPageControl(PageControl.getUnlimitedInstance()); rc.addFilterInventoryStatus(InventoryStatus.DELETED); var dr = ResourceManager.findResourcesByCriteria(rc); pretty.print(dr);'
    

    If any resources are returned, this solution applies.

SBR
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.