Lukas-

I was just looking at this one and thinking a bit about the best way to fix it.
 
As I recall, when we discussed this briefly at the F2F, it was agreed that the main reason we were leaving DELETED Resources in inventory was so that if the Resource got rediscovered (after the underlying managed resource was recreated), it could be re-attached to its old metric data and other histories.

First on the Server side, there is the below code in DiscoveryBossBean.updatePreviouslyInventoriedResource():

        // If the resource was marked as deleted, reactivate it again.
        if (existingResource.getInventoryStatus() == InventoryStatus.DELETED) {
            existingResource.setInventoryStatus(InventoryStatus.COMMITTED);
            existingResource.setPluginConfiguration(updatedResource.getPluginConfiguration());
        }

This has the right idea, but I think it should be changing the status to NEW, not COMMITTED, if it's a platform or a top-level server, since in that case the user should have to import it in order for it to become COMMITTED. The logic would actually be very similar to what we do for newly discovered Resources in initAutoDiscoveredResource(). There is also some other logic in that method we might also want to do like setting the itime to the current time (though I don't know if it makes more sense to leave the itime set to the original pre-DELETED inventory time).

In addition to fixing up the logic in
DiscoveryBossBean, I'm guessing there will also be some changes needed to the sync code in InventoryManager on the agent side. For one thing, if a previously DELETED Resource gets rediscovered, we should make sure it ends up having the same uuid and id as the existing Resource on the Server side, so it doesn't end up getting blown away by purgeObsoleteResources(). I haven't done that much thought on the agent side though - it will probably require a bit of experimentation and debugging to figure out what needs to be changed. In any case, I'd fix up DiscoveryBossBean first.

--Ian

-------- Original Message --------
Subject: [Bug 714812] once a Resource is deleted via RHQ, if the underlying managed resource is later recreated and rediscovered by the Agent, it causes an invalid inventory report error in DiscoveryServerServiceImpl & prevents discovery of any new Resources from that Agent
Date: Wed, 2 Nov 2011 12:05:07 -0400
From: bugzilla@redhat.com
To: ian.springer@redhat.com


Please do not reply directly to this email. All additional
comments should be made in the comments box of this bug.


https://bugzilla.redhat.com/show_bug.cgi?id=714812

Lukas Krejci <lkrejci@redhat.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |lkrejci@redhat.com
         AssignedTo|rhq-maint@redhat.com        |lkrejci@redhat.com

-- 
Configure bugmail: https://bugzilla.redhat.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You reported the bug.