Bug 1284885

Summary: [GSS](6.4.z) CLI Lists in non-interactive mode are erroneously split into multiple commands
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Tom Fonteyne <tfonteyn>
Component: CLIAssignee: Ryan Emerson <remerson>
Status: CLOSED CURRENTRELEASE QA Contact: Peter Mackay <pmackay>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.4.4CC: bbaranow, bmaxwell, brian.stansberry, jboss-set, jtruhlar, msochure, pmackay, remerson
Target Milestone: CR1   
Target Release: EAP 6.4.11   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-01-17 13:13:51 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: 1361648    

Description Tom Fonteyne 2015-11-24 11:51:00 UTC
Installing CP4 on a EAP 6.4 which had some files modified:

Login in the CLI and apply the patch:

[standalone@localhost:9999 /] patch apply jboss-eap-6.4.4-patch.zip
Conflicts detected: bin/init.d/jboss-as-domain.sh, bin/init.d/jboss-as-standalone.sh
Use the --override-all, --override=[] or --preserve=[] arguments in order to resolve the conflict.

Login in the CLI and apply the patch with the -preserve option:
[standalone@localhost:9999 /] patch apply jboss-eap-6.4.4-patch.zip --preserve=bin/init.d/jboss-as-domain.sh,bin/init.d/jboss-as-standalone.sh
{
    "outcome" : "success",
    "response-headers" : {
        "operation-requires-restart" : true,
        "process-state" : "restart-required"
    }
}

=> all fine.

But doing the same directly from bash:

# ./jboss-cli.sh --connect --controller=localhost --commands="patch apply jboss-eap-6.4.4-patch.zip --preserve=bin/init.d/jboss-as-domain.sh,bin/init.d/jboss-as-standalone.sh"
Username: user
Password:
Conflicts detected: bin/init.d/jboss-as-standalone.sh
Use the --override-all, --override=[] or --preserve=[] arguments in order to resolve the conflict.

Playing around with the options (qoutes, escaping) makes no difference.

In this particular case the root cause was the init.d directory had been deleted, but this is of course irrelevant as using the command inside the CLI works ok.

Comment 1 Ryan Emerson 2015-12-09 11:24:17 UTC
The problem arises because commands entered in non-interactive mode are split by the "," character.  Therefore, in the case of:

 "--commands="patch apply jboss-eap-6.4.4-patch.zip --preserve=bin/init.d/jboss-as-domain.sh,bin/init.d/jboss-as-standalone.sh""

the cli is incorrectly splitting the request into two distinct commands:

1. --commands="patch apply jboss-eap-6.4.4-patch.zip --preserve=bin/init.d/jboss-as-domain.sh
2. bin/init.d/jboss-as-standalone.sh



The reason this behaviour is not observed in interactive mode is because multiple commands can not be specified.  However, in non-interactive mode --commands=ls,pwd is valid and should result in the execution of ls followed by pwd.  

This problem is not restricted to the patch command, as it affects all commands entered in non-interactive mode that require a comma-separated list as an argument.  So far this appears to be PatchHanlder.java and ASModuleHandler.java.  Therefore I have renamed this BZ to better reflect the overarching issue.  

My proposed solution requires that lists containing > 1 value must be contained within [] brackets.  This prevents the list from being perceived as multiple commands and allows the list to be passed to the appropriate handler where the [] brackets can be removed and the list processed as expected.

Comment 2 Ryan Emerson 2015-12-09 11:26:40 UTC
Example input for non-interactive mode with the above solution:

./bin/jboss-cli.sh --connect --controller=localhost --commands= ls,patch apply ~/Downloads/jboss-eap-6.4.4-patch.zip  --override=[bin/init.d/jboss-as-domain.sh,bin/init.d/jboss-as-standalone.sh]

Comment 6 JBoss JIRA Server 2016-02-02 10:07:52 UTC
Ryan Emerson <remerson> updated the status of jira JBEAP-2318 to Resolved

Comment 7 JBoss JIRA Server 2016-02-04 16:20:18 UTC
Ryan Emerson <remerson> updated the status of jira WFCORE-1199 to Reopened

Comment 8 JBoss JIRA Server 2016-02-04 16:39:44 UTC
Ryan Emerson <remerson> updated the status of jira JBEAP-2318 to Reopened

Comment 9 JBoss JIRA Server 2016-02-04 16:43:28 UTC
Brian Stansberry <brian.stansberry> updated the status of jira WFCORE-1199 to Resolved

Comment 11 Mike McCune 2016-03-28 23:25:37 UTC
This bug was accidentally moved from POST to MODIFIED via an error in automation, please see mmccune with any questions

Comment 12 JBoss JIRA Server 2016-07-13 16:41:21 UTC
Jiri Pallich <jpallich> updated the status of jira JBEAP-2318 to Closed

Comment 13 Peter Mackay 2016-10-03 17:08:02 UTC
Verified with EAP 6.4.11.CP.CR1

Comment 14 Petr Penicka 2017-01-17 13:13:51 UTC
Retroactively bulk-closing issues from released EAP 6.4 cummulative patches.

Comment 15 Petr Penicka 2017-01-17 13:15:20 UTC
Retroactively bulk-closing issues from released EAP 6.4 cumulative patches.