Bug 976227

Summary: Remote Agent Install doens't work
Product: [Other] RHQ Project Reporter: C Salperwyck <csalperwyck>
Component: AgentAssignee: John Mazzitelli <mazz>
Status: ON_DEV --- QA Contact:
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.7CC: csalperwyck, 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:
Attachments:
Description Flags
printscreen of the server side
none
printscreen of the agent side none

Description C Salperwyck 2013-06-20 07:28:00 UTC
Description of problem:
Can't install remotly an agent from RHQ Server UI

Version-Release number of selected component (if applicable):
Server: Windows 8
Agent: Centos 6.3

How reproducible:
Try to install an agent from a Windows server to a Linux agent (perhaps it doesn't work on other case)

Actual results:
we can see that the file is downloaded in the good directory but its name is like "C:\Devel\rhq-server-4.7.0\modules\org\rhq\rhq-enterprise-server-startup-subsystem\main\deployments\rhq.ear\rhq-downloads\rhq-agent\rhq-enterprise-agent-4.7.0.jar"
instead of:
"rhq-enterprise-agent-4.7.0.jar"
and therefore it can't be installed after being downloaded

Expected results:
the downloaded file on this agent should be:
"rhq-enterprise-agent-4.7.0.jar"

Comment 1 John Mazzitelli 2013-06-29 21:24:12 UTC
i'll take a look at this Monday.

Comment 2 John Mazzitelli 2013-07-01 18:18:26 UTC
i'm having trouble getting my windows environment running. since the description of the issue didn't provide any details such as debug log messages from the server log, I don't even know where in the server this is happening.

Can I ask the reporter to rerun the RHQ server (start with a cleaned out logs/ directory) in debug mode and then post the server log once you get this error again?

Comment 3 C Salperwyck 2013-07-02 15:47:33 UTC
Created attachment 767811 [details]
printscreen of the server side

Comment 4 C Salperwyck 2013-07-02 15:51:50 UTC
Created attachment 767812 [details]
printscreen of the agent side

Comment 5 John Mazzitelli 2013-07-02 16:02:49 UTC
can you provide the server logs? See my previous comment:

> ... rerun the RHQ server (start with a cleaned out logs/ directory)
> in debug mode and then post the server log once you get this error again?

the debug logs will be able to help pinpoint some details in the server internals. screen snapshots does not provide this level of detail needed.

Comment 6 C Salperwyck 2013-07-02 16:05:14 UTC
17:36:13,483 INFO  [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) Running SSH command [Machine uname]
17:36:14,549 DEBUG [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) SSH reading exit status=0
17:36:14,549 DEBUG [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) SSH reading exit status=0
17:36:14,549 INFO  [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) Result of SSH command [Machine uname]: Linux localhost.localdomain 2.6.32-279.19.1.el6.x86_64 #1 SMP Wed Dec 19 07:05:20 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
17:36:14,550 INFO  [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) Running SSH command [Java Version Check]
17:36:15,612 DEBUG [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) SSH reading exit status=0
17:36:15,612 DEBUG [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) SSH reading exit status=0
17:36:15,612 INFO  [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) Result of SSH command [Java Version Check]: java version "1.6.0_24"
17:36:15,612 INFO  [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) Running SSH command [Create Agent Install Directory]
17:36:16,674 DEBUG [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) SSH reading exit status=0
17:36:16,674 DEBUG [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) SSH reading exit status=0
17:36:16,674 INFO  [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) Result of SSH command [Create Agent Install Directory]: 
17:36:16,674 INFO  [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) Copying agent binary update distribution file to [10.22.1.30]...
17:36:17,704 INFO  [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) Agent binary update distribution file copied
17:36:17,704 INFO  [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) Running SSH command [Change to install directory]
17:36:17,765 DEBUG [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) SSH reading exit status=0
17:36:17,765 DEBUG [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) SSH reading exit status=0
17:36:17,765 INFO  [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) Result of SSH command [Change to install directory]: 
17:36:17,765 INFO  [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) Running SSH command [Install Agent]
17:36:17,827 DEBUG [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) SSH reading exit status=1
17:36:17,828 DEBUG [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) SSH reading exit status=1
17:36:17,828 INFO  [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) Result of SSH command [Install Agent]: null
17:36:17,828 INFO  [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) Will start new agent @ [10.22.1.30] pointing to server @ [CSALPERWYCK-DT.akio.fr]
17:36:17,828 INFO  [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) Running SSH command [Start New Agent]
17:36:18,890 DEBUG [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) SSH reading exit status=0
17:36:18,890 DEBUG [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) SSH reading exit status=0
17:36:18,890 INFO  [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) Result of SSH command [Start New Agent]: 
17:36:19,262 INFO  [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) Running SSH command [Find Agent Install Path]
17:36:20,324 DEBUG [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) SSH reading exit status=0
17:36:20,324 DEBUG [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) SSH reading exit status=0
17:36:20,324 INFO  [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) Result of SSH command [Find Agent Install Path]: /home/akiotest/.java/.userPrefs/rhq-agent
17:36:20,324 INFO  [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) Running SSH command [Find Agent Install Path]
17:36:21,386 DEBUG [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) SSH reading exit status=0
17:36:21,386 DEBUG [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) SSH reading exit status=0
17:36:21,386 INFO  [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) Result of SSH command [Find Agent Install Path]: /home/akiotest/.java/.userPrefs/rhq-agent
17:36:21,386 INFO  [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) Running SSH command [Agent Install Check]
17:36:22,448 DEBUG [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) SSH reading exit status=0
17:36:22,448 DEBUG [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) SSH reading exit status=0
17:36:22,448 INFO  [org.rhq.enterprise.server.install.remote.SSHInstallUtility] (http-/0.0.0.0:7080-3) Result of SSH command [Agent Install Check]:

Comment 7 John Mazzitelli 2013-07-02 17:30:21 UTC
I think I may have found the issue (though I don't have a Windows machine right now to confirm):

The method:

org.rhq.enterprise.server.install.remote.SSHFileSend.sendFile(Session, String, String)

has this code in it:

            //send "C0644 filesize filename" where filename doesn't contain a /
            long filesize = (new File(sourceFilename)).length();
            command = "C0644 " + filesize + " ";
            if (sourceFilename.lastIndexOf('/') > 0) {
                command += sourceFilename.substring(sourceFilename.lastIndexOf('/') + 1);
            } else {
                command += sourceFilename;
            }

I think we need to check for Windows separators here (\) as well as Linux separators (/).

Comment 8 John Mazzitelli 2013-07-02 17:51:28 UTC
git commit 70db4e0 checks for Windows separator in the source path and strips the file name if one is found.

I'm skeptical this actually fixes the problem, because it turns out this only touches the source filename, not the destination (and I think its the destFilename parameter that is causing the issue) but I don't know for sure. Would need someone on Windows who can build and test to confirm this fix actually works.

Comment 9 C Salperwyck 2013-07-05 08:20:36 UTC
I can do the test but do you have a night build? or what module should I build and replace? (I would like to avoid to dl all rhq sources ;-))

By the way, why you don't use the function "File.separator" to have just one condition?