Bug 1090829 - Able to install agent more than one time on different location for the same user on same machine
Summary: Able to install agent more than one time on different location for the same u...
Alias: None
Product: RHQ Project
Classification: Other
Component: Core UI
Version: 4.11
Hardware: Unspecified
OS: Unspecified
high vote
Target Milestone: GA
: RHQ 4.11
Assignee: John Mazzitelli
QA Contact: Mike Foley
Depends On:
Blocks: JON3-30, PRODMGT-542 1129290
TreeView+ depends on / blocked
Reported: 2014-04-24 09:20 UTC by Jeeva Kandasamy
Modified: 2014-08-12 14:07 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1129290 (view as bug list)
Last Closed: 2014-07-21 10:14:05 UTC

Attachments (Terms of Use)
Multiple entries in "rhq_agent_install" table (37.81 KB, image/jpeg)
2014-04-24 15:06 UTC, Jeeva Kandasamy
no flags Details

Description Jeeva Kandasamy 2014-04-24 09:20:08 UTC
Description of problem:
Try to install remote agent more than one time on same machine with different locations with same user. First installation went success and agent up and running. Second time installed on different location and up, but throws an exception saying the port already in use. 

2014-04-24 14:29:52,512 ERROR [main] (org.rhq.enterprise.agent.AgentMain)- {AgentMain.start-failure}Failed to start the agent. Cause: java.io.IOException: SocketServerInvoker[] error creating ServerSocket[]: Address already in use

ps -ef | grep rhq
[jenkins@rhel-6-gui tmp]$ ps -ef | grep rhq
jenkins  16462     1  0 Apr23 ?        00:01:12 /usr/bin/java -Djava.endorsed.dirs=/tmp/rhq-agent/lib/endorsed -Djava.library.path=/tmp/rhq-agent/lib -Djna.platform.library.path=/tmp/rhq-agent/lib/augeas/lib64 -Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true -Drhq.preferences.file=/tmp/rhq-agent/conf/agent-prefs.properties -Dlog4j.configuration=log4j.xml -cp /tmp/rhq-agent/conf:/tmp/rhq-agent/lib/commons-io-1.4.jar:/tmp/rhq-agent/lib/commons-logging-1.1.0.jboss.jar:/tmp/rhq-agent/lib/concurrent-1.3.4-jboss-update1.jar:/tmp/rhq-agent/lib/getopt-1.0.13.jar:/tmp/rhq-agent/lib/i18nlog-1.0.10.jar:/tmp/rhq-agent/lib/jboss-common-core-2.2.17.GA.jar:/tmp/rhq-agent/lib/jboss-jmx-4.2.3.GA.jar:/tmp/rhq-agent/lib/jboss-logging-3.1.2.GA.jar:/tmp/rhq-agent/lib/jboss-remoting-2.5.4.SP5.jar:/tmp/rhq-agent/lib/jboss-serialization-1.0.3.GA.jar:/tmp/rhq-agent/lib/jline-0.9.94.jar:/tmp/rhq-agent/lib/log4j-1.2.16.jar:/tmp/rhq-agent/lib/persistence-api-1.0.jar:/tmp/rhq-agent/lib/rhq-common-drift-4.11.0-SNAPSHOT.jar:/tmp/rhq-agent/lib/rhq-core-client-api-4.11.0-SNAPSHOT.jar:/tmp/rhq-agent/lib/rhq-core-comm-api-4.11.0-SNAPSHOT.jar:/tmp/rhq-agent/lib/rhq-core-domain-4.11.0-SNAPSHOT.jar:/tmp/rhq-agent/lib/rhq-core-native-system-4.11.0-SNAPSHOT.jar:/tmp/rhq-agent/lib/rhq-core-plugin-api-4.11.0-SNAPSHOT.jar:/tmp/rhq-agent/lib/rhq-core-plugin-container-4.11.0-SNAPSHOT.jar:/tmp/rhq-agent/lib/rhq-core-util-4.11.0-SNAPSHOT.jar:/tmp/rhq-agent/lib/rhq-enterprise-agent-4.11.0-SNAPSHOT.jar:/tmp/rhq-agent/lib/rhq-enterprise-comm-4.11.0-SNAPSHOT.jar:/tmp/rhq-agent/lib/sigar- org.rhq.enterprise.agent.AgentMain -Drhq.agent.server.bind-address=rhqbox1.lab.eng.pnq.redhat.com -Drhq.communications.connector.bind-address= -Drhq.agent.configuration-setup-flag=true --daemon -Drhq.install.id=10012
jenkins  16899     1  0 Apr23 ?        00:00:54 /usr/bin/java -Djava.endorsed.dirs=/tmp/tmp/rhq-agent/lib/endorsed -Djava.library.path=/tmp/tmp/rhq-agent/lib -Djna.platform.library.path=/tmp/tmp/rhq-agent/lib/augeas/lib64 -Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true -Drhq.preferences.file=/tmp/tmp/rhq-agent/conf/agent-prefs.properties -Dlog4j.configuration=log4j.xml -cp /tmp/tmp/rhq-agent/conf:/tmp/tmp/rhq-agent/lib/commons-io-1.4.jar:/tmp/tmp/rhq-agent/lib/commons-logging-1.1.0.jboss.jar:/tmp/tmp/rhq-agent/lib/concurrent-1.3.4-jboss-update1.jar:/tmp/tmp/rhq-agent/lib/getopt-1.0.13.jar:/tmp/tmp/rhq-agent/lib/i18nlog-1.0.10.jar:/tmp/tmp/rhq-agent/lib/jboss-common-core-2.2.17.GA.jar:/tmp/tmp/rhq-agent/lib/jboss-jmx-4.2.3.GA.jar:/tmp/tmp/rhq-agent/lib/jboss-logging-3.1.2.GA.jar:/tmp/tmp/rhq-agent/lib/jboss-remoting-2.5.4.SP5.jar:/tmp/tmp/rhq-agent/lib/jboss-serialization-1.0.3.GA.jar:/tmp/tmp/rhq-agent/lib/jline-0.9.94.jar:/tmp/tmp/rhq-agent/lib/log4j-1.2.16.jar:/tmp/tmp/rhq-agent/lib/persistence-api-1.0.jar:/tmp/tmp/rhq-agent/lib/rhq-common-drift-4.11.0-SNAPSHOT.jar:/tmp/tmp/rhq-agent/lib/rhq-core-client-api-4.11.0-SNAPSHOT.jar:/tmp/tmp/rhq-agent/lib/rhq-core-comm-api-4.11.0-SNAPSHOT.jar:/tmp/tmp/rhq-agent/lib/rhq-core-domain-4.11.0-SNAPSHOT.jar:/tmp/tmp/rhq-agent/lib/rhq-core-native-system-4.11.0-SNAPSHOT.jar:/tmp/tmp/rhq-agent/lib/rhq-core-plugin-api-4.11.0-SNAPSHOT.jar:/tmp/tmp/rhq-agent/lib/rhq-core-plugin-container-4.11.0-SNAPSHOT.jar:/tmp/tmp/rhq-agent/lib/rhq-core-util-4.11.0-SNAPSHOT.jar:/tmp/tmp/rhq-agent/lib/rhq-enterprise-agent-4.11.0-SNAPSHOT.jar:/tmp/tmp/rhq-agent/lib/rhq-enterprise-comm-4.11.0-SNAPSHOT.jar:/tmp/tmp/rhq-agent/lib/sigar- org.rhq.enterprise.agent.AgentMain -Drhq.agent.server.bind-address=rhqbox1.lab.eng.pnq.redhat.com -Drhq.communications.connector.bind-address= -Drhq.agent.configuration-setup-flag=true --daemon -Drhq.install.id=10031
jenkins  22597 22206  0 14:32 pts/4    00:00:00 grep rhq

Version-Release number of selected component (if applicable):
Version : 4.11.0-SNAPSHOT
Build Number : 1bc9904
GWT Version : 2.5.0
SmartGWT Version : 3.0

Browser: Firefox 28

How reproducible:

Steps to Reproduce:
1. Navigate to "Administration-->Agents-->New"
2. Enter remote box details (Agent should not be installed), give some location, example: /tmp/
3. Click on "install Agent", will be installed successfully
4. Again Navigate to "Administration-->Agents-->New"
5. Enter remote box details same as in step #2, give different location location, example: /tmp/another/
6. Click on "install Agent", will be installed successfully. But the port already use with agent installed on step #3.
7. Second installation should refer first installation location and should not proceed more than one time.

Actual results:
Permits second installation on different location for the same user on the same machine.

Expected results:
Should not install more than one time, if a agent is already installed on different location. We should track with some reference in common location.

Comment 1 Jeeva Kandasamy 2014-04-24 15:06:21 UTC
Created attachment 889323 [details]
Multiple entries in "rhq_agent_install" table

in the above case, If we install multiple times, we can see more than one entry in "rhq_agent_install" table,

rhq=# select * from rhq_agent_install;
  id   |     mtime     |           agent_name           |                 install_location                 |   ssh_host   | ssh_port | ssh_username |   ssh_password   
 10001 | 1398210095484 | rhqbox1.lab.eng.pnq.redhat.com | /home/hudson/rhq-server-location-fresh/rhq-agent | |          |              | 
 10011 | 1398229679011 |                                |                                                  |  |       22 |              | 
 10013 | 1398308668469 |                                |                                                  |  |       22 | jenkins      | 606f83b302d3426d
 10012 | 1398309707006 | rhel-6-gui                     | /tmp/tmp/tmp/rhq-agent                           |  |       22 | jenkins      | 606f83b302d3426d
 10031 | 1398235247519 |                                |                                                  |  |       22 |              | 
(5 rows)

Screen shot is attached.

Comment 2 John Mazzitelli 2014-04-24 16:10:09 UTC
Its possible multiple rows in rhq_agent_install table will show up under a few scenarios. We clean it up later when other things happen. In other words, rhq_agent_install table is an internal implementation detail that shouldn't concern end users.

As for the issue of installing multiple agents on the same machine, I am going to look into doing something like looking in the rhq_agent table to see if one is already registered. I might be able to use rhq_agent_install table as well, but I'll figure this out once I start working on it.

Comment 3 John Mazzitelli 2014-04-24 20:21:41 UTC
I think the best thing to do here is to see if the port is already in use. If the port is in use, not only will this abort if another agent was installed, but it will abort if anything has taken the port the agent wants to use. This is helpful for other use-cases as well (as in the case of installing an agent on a machine where some other application is using the port the agent wants to use).

This has been implemented, git commit to master: c911e9a

Comment 4 Heiko W. Rupp 2014-07-21 10:14:05 UTC
Bulk closing of RHQ 4.11 issues, now that RHQ 4.12 is out.

If you find an issue with those, please open a new BZ, linking to the old one.

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