Bug 1139607 - EAP cli script fails always during bundle deployment to domain server
Summary: EAP cli script fails always during bundle deployment to domain server
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Operations Network
Classification: JBoss
Component: Provisioning
Version: JON 3.3.0
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ER03
: JON 3.3.0
Assignee: Thomas Segismont
QA Contact: Armine Hovsepyan
URL:
Whiteboard:
Keywords:
Depends On:
Blocks: 1050014
TreeView+ depends on / blocked
 
Reported: 2014-09-09 10:21 UTC by Armine Hovsepyan
Modified: 2015-09-03 00:03 UTC (History)
4 users (show)

(edit)
Clone Of:
(edit)
Last Closed: 2014-12-11 14:04:02 UTC


Attachments (Terms of Use)
domain_delp (156.95 KB, application/octet-stream)
2014-09-17 14:28 UTC, Armine Hovsepyan
no flags Details

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@redhat.com>
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@redhat.com>
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@redhat.com>

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


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