Bug 683859 - ResourceCriteria does not filter out deleted child resources
ResourceCriteria does not filter out deleted child resources
Status: ON_DEV
Product: RHQ Project
Classification: Other
Component: Core Server (Show other bugs)
3.0.0
Unspecified Unspecified
unspecified Severity unspecified (vote)
: ---
: ---
Assigned To: RHQ Project Maintainer
Mike Foley
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-03-10 09:24 EST by John Sanda
Modified: 2011-05-23 20:59 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description John Sanda 2011-03-10 09:24:47 EST
Description of problem:
I discovered a problem with ResourceCriteria while I was working in the CLI. I deleted a webapp and then fetched the parent JBoss AS resource with the following resource criteria:

// begin code
criteria = ResourceCriteria();
criteria.addFilterId(jbossId);
criteria.fetchChildResources(true);

resource = ResourceManager.findResourcesByCriteria(criteria);
// end code

Even though my webapp already had an inventory status of DELETED it was still included in resource.childResources. It should not be though. Logic has been put in place wherever resources are queried to filter out deleted resources that still exist in the database but have not yet been purged. ResourceCriteria needs to be updated to exclude deleted child resources.

I have not checked yet, but this seem problem might exist with fetching child resource types.
 
Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:
Comment 1 John Sanda 2011-03-10 16:19:04 EST
I talked at length with Jay Shaughnessy about this. He explained that the problem here is not with ResourceCriteria. If the generated query from the ResourceCriteria object filtered out deleted child resources, then the parent resource would also get excluded. We would need to filter on the resource returned from the initial query, which would be rather inefficient. As an aside, Hibernate does offer collection filtering that is done at the database which we could use but it does not address the problem in its entirety. Conceptually from the user's standpoint, a resource that is marked deleted should be no different than a resource that has been physically deleted from the database. The solution might be as Jay suggested to break the relationship between parent and child resources.
Comment 2 John Sanda 2011-03-11 16:45:36 EST
Turns out that the immediate issue is ResourceFactoryManagerBean.completeDeleteResourceRequest. The deleted resource is not uninventoried as I thought was the case. Instead, ResourceFactoryManagerBean just sets the resource's inventory status to DELETED, leaving the parentResource link intact. I have added a call to remove the parentResource link so that the deleted child resource is no longer accessible by its parent.

commit hash: 4bc6d8ef2ecb6d7358934a85b5261471072f93a0

Note You need to log in before you can comment on or make changes to this bug.