Bug 1029610 - Two platforms created for a single agent; one Java one Linux
Two platforms created for a single agent; one Java one Linux
Status: ASSIGNED
Product: RHQ Project
Classification: Other
Component: Agent (Show other bugs)
4.9
Unspecified Unspecified
unspecified Severity unspecified (vote)
: ---
: ---
Assigned To: Michael Burman
Mike Foley
:
Depends On:
Blocks: 1117449 1128210
  Show dependency treegraph
 
Reported: 2013-11-12 12:44 EST by Elias Ross
Modified: 2014-08-08 11:18 EDT (History)
3 users (show)

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


Attachments (Terms of Use)
duplicate platform in invenetory (30.13 KB, image/png)
2013-11-12 12:44 EST, Elias Ross
no flags Details

  None (edit)
Description Elias Ross 2013-11-12 12:44:02 EST
Created attachment 823065 [details]
duplicate platform in invenetory

Description of problem:

See attached screenshot.

One of the servers was created with two associated platform instances.

It creates all sorts of problems, like the following:

2013-11-12 17:33:19,267 INFO  [InventoryManager.discovery-1] (AutoDiscoveryExecutor)- Discovered new platform with 3 child server(s).
2013-11-12 17:33:19,267 INFO  [InventoryManager.discovery-1] (InventoryManager)- Sending [server] inventory report to Server...
2013-11-12 17:33:19,437 WARN  [InventoryManager.discovery-1] (AutoDiscoveryExecutor)- Exception caught while executing server discovery scan.
[Warning] javax.ejb.EJBTransactionRolledbackException: result returns more than one elements
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:138)
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:228)
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:317)
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:214)        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
        at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
        at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64)
        at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
        at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
        at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:54)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
        at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
        at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
        at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)
        at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:182)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
        at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
        at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72)
        at org.rhq.enterprise.server.discovery.DiscoveryBossLocal$$$view100.getResourceSyncInfo(Unknown Source)
        at org.rhq.enterprise.server.discovery.DiscoveryBossBean.mergeInventoryReport(DiscoveryBossBean.java:237)



Version-Release number of selected component (if applicable): 4.9


How reproducible: Unclear, only one out of a thousand servers. The server itself could have been under a lot of load, or some other condition during the upgrade.


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:
Comment 1 Elias Ross 2013-11-12 12:51:15 EST
Also trying to remove the agent itself results in:

17:46:03,335 WARN  [org.rhq.enterprise.gui.coregui.server.gwt.ResourceGWTServiceImpl] (http-/0.0.0.0:7081-695) Sending exception to client: [1384278363335] : javax.ejb.EJBExcepti
on: javax.persistence.NonUniqueResultException: result returns more than one elements
...
        at org.rhq.enterprise.server.resource.ResourceManagerLocal$$$view22.uninventoryAllResourcesByAgent(Unknown Source) [rhq-server.jar:4.9.0]
        at org.rhq.enterprise.gui.coregui.server.gwt.ResourceGWTServiceImpl.uninventoryAllResourcesByAgent(ResourceGWTServiceImpl.java:280) [classes:]


public class ResourceManagerBean implements ResourceManagerLocal, ResourceManagerRemote {

    public Resource getPlatform(Agent agent) {
        Query query = entityManager.createNamedQuery(Resource.QUERY_FIND_PLATFORM_BY_AGENT);
        query.setParameter("category", ResourceCategory.PLATFORM);
        query.setParameter("agent", agent);

        try {
            Resource platform = (Resource) query.getSingleResult();
^^^
            return platform;
        } catch (NoResultException e) {
            //this means that the agent didn't send any info to us yet.
            //this can happen during the inital resource upgrade sync between
            //the agent and server.
            return null;
        }
    }


This method should probably guard against multiple entries being returned.
Comment 2 Elias Ross 2014-05-15 20:40:12 EDT
The work-around this problem mostly works:

1) First find the resources for the agent:

select * from rhq_resource where agent_id = 14439
order by resource_type_id 

2) The Platform resource should appear as resource type in the lower numbers, but be called 'Java' or something. Change the type ID to another type, like '10016' (file system), also set the parent resource ID. Update the row. Then go to the UI and uninventory.
Comment 3 Jay Shaughnessy 2014-08-08 11:02:18 EDT
master commit 90794dc7a122a1f519bc7f96fa2078d697a160f5
Author: Jay Shaughnessy <jshaughn@redhat.com>
Date:   Fri Aug 1 15:09:12 2014 -0400

    Add some logging that would have been helpful investigating this issue.
Comment 4 Jay Shaughnessy 2014-08-08 11:18:46 EDT
master commit 2a09fd40f5d0b25c5d1c3ba37c553095dc366e60
Author: burmanm <miburman@redhat.com>
Date:   Tue Aug 5 21:38:40 2014 +0300

    Add logging to NativeSystemInfo to detect why Java platform was selected

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