Bug 1139607

Summary: EAP cli script fails always during bundle deployment to domain server
Product: [JBoss] JBoss Operations Network Reporter: Armine Hovsepyan <ahovsepy>
Component: ProvisioningAssignee: Thomas Segismont <tsegismo>
Status: CLOSED CURRENTRELEASE QA Contact: Armine Hovsepyan <ahovsepy>
Severity: high Docs Contact:
Priority: unspecified    
Version: JON 3.3.0CC: gkhachik, lkrejci, mfoley, tsegismo
Target Milestone: ER03   
Target Release: JON 3.3.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-12-11 14:04:02 UTC 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:
Bug Depends On:    
Bug Blocks: 1050014    
Attachments:
Description Flags
domain_delp none

Description Armine Hovsepyan 2014-09-09 10:21:52 UTC
Description of problem:
EAP cli script fails always during bundle deployment to domain server 

Version-Release number of selected component (if applicable):
JON 3.3 ER02

How reproducible:
always

Steps to Reproduce:
1. install and start EAP server in domain mode
2. create a bundle containing cli script  (containing only ls command)
3. deploy bundle to eap domain server

Actual results:
deployment fails with handover error

Expected results:
deployment passes 

Additional info:
operation run for the same script passes on eap domain server

Comment 1 Thomas Segismont 2014-09-09 10:37:46 UTC
Lukas, I ran Armine's test agent in debug mode and actually the CLI script execution fails with the following error:

============
File /home/hudson/jboss-eap6-domain/data/tmp/prepareDatasource.cli2952106056583414403.tmp doesn't exist.
============

It is a regression introduced after the creation of the ServerControl class.

In BaseServerComponent#handleExecuteScript, before:
==============
scriptFile = File.createTempFile(handoverRequest.getFilename(), ".tmp", context.getTemporaryDirectory());
FileUtil.writeFile(handoverRequest.getContent(), scriptFile);

CliExecutor cliExecutor = new CliExecutor(getMode(), getServerPluginConfiguration(),
    getStartScriptConfiguration(), context.getSystemInformation());
ProcessExecutionResults results = cliExecutor.executeCliScript(scriptFile.getAbsolutePath(), waitTime,
    killOnTimeout);
==============

Note the "scriptFile.getAbsolutePath()" invocation.

After:
=============
scriptFile = File.createTempFile(handoverRequest.getFilename(), ".tmp", context.getTemporaryDirectory());
FileUtil.writeFile(handoverRequest.getContent(), scriptFile);

ProcessExecutionResults results = CliExecutor.onServer(
    getServerPluginConfiguration().getPluginConfig(), getMode(), context.getSystemInformation())
    .waitingFor(waitTime).killingOnTimeout(killOnTimeout).executeCliScript(scriptFile);
=============


and in ServerControl.Cli#executeCliScript:
=============
File homeDir = serverPluginConfig.getHomeDir();

File script = scriptFile;
if (!script.isAbsolute()) {
    script = new File(homeDir, scriptFile.getPath());
}
=============


Did you introduce the code above to support the execution of CLI scripts defined by relative path in the the server resource operation parameters?

I guess all I need to do to fix the bug is to make BaseServerComponent#handleExecuteScript call ServerControl.Cli#executeCliScript with an absolute File object, but I'm not sure I'm not missing something.

Comment 2 Lukas Krejci 2014-09-09 12:20:22 UTC
+1 Thomas, this seems to be a confusion on my side... the path should of course be absolute because when the file object is created, it is relative to CWD of the agent but then passed as a path to the jboss-cli.sh which has different CWD.

I think we should change this as you suggested.

Comment 3 Lukas Krejci 2014-09-09 12:24:01 UTC
For the reasoning about the relative paths handling in ServerControl: when I was putting together the ServerControl class from the various code snippets around the codebase, this seemed to be the expected behavior - i.e. if the path is relative, resolve it against homeDir.

Not sure if that's been the behavior in all the places that are now invoking ServerControl - at least the instance we just discovered wasn't... :(

Comment 4 Thomas Segismont 2014-09-10 16:47:55 UTC
Fixed in master

commit b6795f890782266d4ab23b825cf6ba7356b0fba3
Author: Thomas Segismont <tsegismo>
Date:   Wed Sep 10 18:46:21 2014 +0200

    Bug 1139607 - EAP cli script fails always during bundle deployment to domain server
    
    #executeCliScript should be called with an absolute File reference.
    
    Side work:
    * convert script File reference to absolute when the execute-script command is executed
    * log results of handed-over script's execution
    * some code cleanup

Comment 5 Thomas Segismont 2014-09-12 13:17:15 UTC
Cherry-picked over to release/jon3.3.x

commit a719cf491840348da929bc41dc309e1f0d4f69f7
Author: Thomas Segismont <tsegismo>
Date:   Wed Sep 10 18:46:21 2014 +0200

    Bug 1139607 - EAP cli script fails always during bundle deployment to domain server
    
    #executeCliScript should be called with an absolute File reference.
    
    Side work:
    * convert script File reference to absolute when the execute-script command is executed
    * log results of handed-over script's execution
    * some code cleanup
    
    (cherry picked from commit b6795f890782266d4ab23b825cf6ba7356b0fba3)
    Signed-off-by: Thomas Segismont <tsegismo>

Comment 6 Simeon Pinder 2014-09-17 02:49:17 UTC
Moving to ON_QA as available for test with the following brew build:
https://brewweb.devel.redhat.com//buildinfo?buildID=385149

Comment 7 Armine Hovsepyan 2014-09-17 14:28:31 UTC
Created attachment 938498 [details]
domain_delp

Comment 8 Armine Hovsepyan 2014-09-17 14:29:28 UTC
deployment with cli script for domain server works in JON 3.3 ER03 - screenshot attached