Bug 580175
Summary: | Reoccurring scheduled resource operation is not deleted when resource's platform is removed from inventory | ||||||
---|---|---|---|---|---|---|---|
Product: | [Other] RHQ Project | Reporter: | John Sanda <jsanda> | ||||
Component: | Inventory | Assignee: | John Sanda <jsanda> | ||||
Status: | CLOSED CURRENTRELEASE | QA Contact: | Corey Welton <cwelton> | ||||
Severity: | medium | Docs Contact: | |||||
Priority: | low | ||||||
Version: | 3.0.0 | CC: | cathy.degagne, rtimaniy | ||||
Target Milestone: | --- | ||||||
Target Release: | --- | ||||||
Hardware: | All | ||||||
OS: | Linux | ||||||
Whiteboard: | |||||||
Fixed In Version: | 2.4 | Doc Type: | Bug Fix | ||||
Doc Text: | Story Points: | --- | |||||
Clone Of: | Environment: | ||||||
Last Closed: | 2010-08-12 16:58:16 UTC | Type: | --- | ||||
Regression: | --- | Mount Type: | --- | ||||
Documentation: | --- | CRM: | |||||
Verified Versions: | Category: | --- | |||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
Cloudforms Team: | --- | Target Upstream Version: | |||||
Embargoed: | |||||||
Bug Depends On: | 583669 | ||||||
Bug Blocks: | 576714 | ||||||
Attachments: |
|
Description
John Sanda
2010-04-07 16:10:17 UTC
After discussion and review with the dev code, it appears that the defect is in ResourceManagerBean.deleteResource(Subject subject, int resourceId) which is called to remove a resource and its children from inventory. The resource to be remove has its associated scheduled jobs removed, but scheduled jobs for the child resources are not deleted. Pushed commits to the bugfixes branch that make two changes. First, in the classes ResourceOperationJob and GroupOperationJob logic has been added to see if the resource is null (i.e., already deleted in db) or does not have a committed inventory status. If either of these conditions holds, a CancelJobException is throw and future executions of the job are canceled. Secondly, the code in ResourceManagerBean that deletes a resource's scheduled jobs when the resource is being marked for removal has been moved to AsyncResourceDeleteJob so that it is done asynchronously. And now the jobs for child resources are deleted as well. These commits have been merged into master. Moving to ON_QA. Created attachment 407595 [details]
A simple function for scheduling a reoccurring resource operation
Rajan, I have just attached a script to this bug that you can use to schedule a resource operation job from the CLI. Once you are logged into the CLI, load the script as follows, rhqadmin@localhost:7080$ exec -f schedule_job.js In the above example it assumes that the script is in the current working directory. If the script is in another directory, be sure to specify the path to it, e.g., exec -f /path/to/schedule_job.js. This binds the function schedule_resource_operation into the script context. The function expects two arguments - the resource id and the operation name. You might invoke the function in the following way, rhqadmin@localhost:7080$ resourceId = 1234 rhqadmin@localhost:7080$ operationName = "execute" rhqadmin@localhost:7080$ schedule_resource_operation(resourceId, operationName) The function schedules the operation to execute every 30 seconds indefinitely. I have provided comments and variables in the function to make it easy for you to tweak the values. This should do the trick. Verified on JON build #108 - Revision: 10611 The scheduled jobs has been removed along side with the resources that are being removed from inventory. Stpes: 1. Create a reoccurring scheduled operation for 'RHQ Agent' and set the repeat interval to 30 sec. 2. Remove the parent platform of the resource from inventory. 3. Wait until you see in the server log that the resource has been removed from the database. 3.1. Log message like, 2010-04-22 18:02:24,797 INFO [org.rhq.enterprise.server.resource.ResourceManagerBean] User [org.rhq.core.domain.auth.Subject[id=2,name=rhqadmin]] is marking resource [Resource[id=14311, type=Linux, key=rajanlaptop.usersys.redhat.com, name=rajanlaptop.usersys.redhat.com, parent=<null>, version=Linux 2.6.18-164.11.1.el5PAE]] for asynchronous deletion 2010-04-22 18:02:25,443 WARN [org.rhq.enterprise.server.core.comm.ServerCommunicationsService] {Failed to truncate/delete spool for deleted agent [Agent[id=10011,name=rajanlaptop.usersys.redhat.com,address=rajanlaptop.usersys.redhat.com,port=16163,remote-endpoint=socket://rajanlaptop.usersys.redhat.com:16163/?rhq.communications.connector.rhqtype=agent&numAcceptThreads=1&maxPoolSize=303&clientMaxPoolSize=304&socketTimeout=60000&enableTcpNoDelay=true&backlog=200,last-availability-report=1271939520757]] please manually remove the file: null}!!! missing resource message key=[Failed to truncate/delete spool for deleted agent [Agent[id=10011,name=rajanlaptop.usersys.redhat.com,address=rajanlaptop.usersys.redhat.com,port=16163,remote-endpoint=socket://rajanlaptop.usersys.redhat.com:16163/?rhq.communications.connector.rhqtype=agent&numAcceptThreads=1&maxPoolSize=303&clientMaxPoolSize=304&socketTimeout=60000&enableTcpNoDelay=true&backlog=200,last-availability-report=1271939520757]] please manually remove the file: null] args=[java.lang.NullPointerException] 2010-04-22 18:02:25,443 INFO [org.rhq.enterprise.server.core.AgentManagerBean] Removed agent: Agent[id=10011,name=rajanlaptop.usersys.redhat.com,address=rajanlaptop.usersys.redhat.com,port=16163,remote-endpoint=socket://rajanlaptop.usersys.redhat.com:16163/?rhq.communications.connector.rhqtype=agent&numAcceptThreads=1&maxPoolSize=303&clientMaxPoolSize=304&socketTimeout=60000&enableTcpNoDelay=true&backlog=200,last-availability-report=1271939520757] 2010-04-22 18:02:25,691 WARN [org.jboss.seam.ui.renderkit.DefaultActionRendererBase] Must set an id for the default action source 2010-04-22 18:02:25,708 ERROR [org.rhq.enterprise.server.discovery.DiscoveryServerServiceImpl] Received invalid inventory report from agent [Agent[id=0,name=rajanlaptop.usersys.redhat.com,address=null,port=0,remote-endpoint=null,last-availability-report=null]]: Unknown Agent named [rajanlaptop.usersys.redhat.com] sent an inventory report - that report will be ignored 2010-04-22 18:02:27,705 INFO [org.rhq.enterprise.server.core.CoreServerServiceImpl] Got agent registration request for new agent: rajanlaptop.usersys.redhat.com[rajanlaptop.usersys.redhat.com:16163][3.0.0-SNAPSHOT(ac4460c)] 2010-04-22 18:02:30,106 WARN [org.rhq.enterprise.server.operation.ResourceOperationJob] The resource with id 14312 is not committed in inventory. It may have been deleted from inventory. Canceling job. 2010-04-22 18:02:30,331 INFO [org.quartz.core.JobRunShell] Job rhq-resource-14312.rhq-resource-14312-1097506319-1271939434370 threw a JobExecutionException: org.rhq.enterprise.server.operation.CancelJobException: The resource with id 14312 is not committed in inventory. It may have been deleted from inventory. Canceling job. at org.rhq.enterprise.server.operation.ResourceOperationJob.invokeOperationOnResource(ResourceOperationJob.java:177) at org.rhq.enterprise.server.operation.ResourceOperationJob.execute(ResourceOperationJob.java:95) at org.quartz.core.JobRunShell.run(JobRunShell.java:202) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525) Mass-closure of verified bugs against JON. |