Bug 1006604

Summary: Agent registration silently fails if server auto-detection and multicast is enabled and another agent with the same name or address is already registered to the server
Product: [Other] RHQ Project Reporter: Larry O'Leary <loleary>
Component: AgentAssignee: Nobody <nobody>
Status: NEW --- QA Contact:
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.4CC: hrupp
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
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: --- Target Upstream Version:
Embargoed:

Description Larry O'Leary 2013-09-10 21:45:07 UTC
Description of problem:
If agent configuration options rhq.agent.server-auto-detection and rhq.communications.multicast-detector.enabled are set to true and another agent is already registered on the target server using the same name or address, the agent simply fails to merge its inventory report without any indication to the user of the failure.

Normally, if you attempt to register an agent to a server with the same agent name or address, you receive an error message on the agent console or in the log that makes it clear what is wrong. But in this case, you do not.

You will receive an agent prompt and all agent prompt commands will fail with the same root exception:

        java.lang.IllegalStateException: The sender object is currently not sending commands now. Command not sent: [Command: type=[remotepojo]; cmd-in-response=[false]; config=[{rhq.timeout=1800000, rhq.send-throttle=true}]; params=[{invocation=NameBasedInvocation[mergeInventoryReport], targetInterfaceName=org.rhq.core.clientapi.server.discovery.DiscoveryServerService}]]
            at org.rhq.enterprise.communications.command.client.ClientCommandSender.sendSynch(ClientCommandSender.java:631)
            at org.rhq.enterprise.communications.command.client.ClientRemotePojoFactory$RemotePojoProxyHandler.invoke(ClientRemotePojoFactory.java:407)
            at $Proxy3.mergeInventoryReport(Unknown Source)
            at org.rhq.core.pc.inventory.InventoryManager.handleReport(InventoryManager.java:1047)
            at org.rhq.core.pc.inventory.AutoDiscoveryExecutor.call(AutoDiscoveryExecutor.java:129)
            at org.rhq.core.pc.inventory.AutoDiscoveryExecutor.run(AutoDiscoveryExecutor.java:91)
            ...

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

How reproducible:
Always

Steps to Reproduce:
1.  Start JBoss ON server.
2.  Start JBoss ON agent using agent name of `original-agent`.
3.  Verify agent is registered and its platform was discovered.
4.  Shutdown agent.
5.  Configure JBoss ON agent for auto-install by updating the following properties in ${RHQ_AGENT_HOME}/conf/agent-configuration.xml:

-               <!--
-               <entry key="rhq.agent.configuration-setup-flag" value="false" />
-               -->
+               <entry key="rhq.agent.configuration-setup-flag" value="true" />

-               <!--
-               <entry key="rhq.agent.name" value="my.hostname.com"/>
-               -->
+               <entry key="rhq.agent.name" value="new-agent"/>

-               <entry key="rhq.agent.server-auto-detection" value="false" />
+               <entry key="rhq.agent.server-auto-detection" value="true" />

-               <entry key="rhq.communications.multicast-detector.enabled"              value="false" />
+               <entry key="rhq.communications.multicast-detector.enabled"              value="true" />


6.  Restart agent using the --cleanconfig command-line argument:

        cd "${RHQ_AGENT_HOME}/bin"
        ./rhq-agent.sh --cleanconfig
        
7.  Execute agent prompt command ping.

Actual results:
Pinging...
Failed to execute prompt command [ping]. Cause: java.lang.IllegalStateException:The sender object is currently not sending commands now. Command not sent: [Command: type=[remotepojo]; cmd-in-response=[false]; config=[{rhq.send-throttle=true}]; params=[{invocation=NameBasedInvocation[ping], targetInterfaceName=org.rhq.enterprise.communications.Ping}]]

Also, agent.log contains warnings and errors with the same IllegalStateException.

Expected results:
Before agent prompt is displayed and error or warning message indicating the agent is not yet communicating with a server or some other indication of why registration is failing.

Additional info:
This was originally reported in JBoss ON but the server auto-detection feature is not supported by JON so I am capturing this here.