Bug 983980

Summary: EAP6 CLI command should not allow same runtime-name to be used at another deploy
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Jay SenSharma <jsenshar>
Component: Domain ManagementAssignee: Emmanuel Hugonnet (ehsavoie) <ehugonne>
Status: CLOSED CURRENTRELEASE QA Contact: Petr Kremensky <pkremens>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.0.1CC: brian.stansberry, dereed, ehugonne, emuckenh, lcosti, olubyans, pkremens, sjadhav
Target Milestone: ER1   
Target Release: EAP 6.2.0   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Two deployments with the same runtime name would incorrectly be allowed to be deployed onto the same JBoss EAP 6 instance. As a result, the instance may enter an inconsistent state in using the runtime name for the wrong deployment. This issue has been fixed in this release of JBoss EAP 6, and a runtime name is now only allowed to be used once per JBoss EAP 6 instance. If an attempt is made to deploy an application with a runtime name already in use, the following error will be displayed: ---- There is already a deployment called ${name} with the same runtime name ${runtime-name} on server group ${server-group} ----
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-12-15 16:14:45 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:

Description Jay SenSharma 2013-07-12 12:42:02 UTC
Description of problem:
If an application is deployed via JBoss CLI utility as following:

deploy /home/jsenshar/myapp.war --runtime-name=abc.war --name=myapp1

Then the context root of the application becomes "/abc" (As runtime name is being treated as Context-Root so even if the app name is myapp.war, Still the context root will be /abc which is good)

However when another application is attempted to be deployed on the same JBoss with the same "runtime-name" still JBoss CLI/JBoss Container does not throw any error as the "/abc" context is already registered with the same name.

Example:
deploy /home/jsenshar/myapp.war --runtime-name=abc.war --name=myapp2

So second time when abc.war is being deployed with different "name" (however the "runtime-name" is same as pervious) then JBoss/CLI should throw error Rather than uploading the Applciation content in the "data/content" directory.



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


How reproducible:
Step-1).
======== Deploy "myapp.war" as following:
[standalone@localhost:9999 /] deploy /home/jsenshar/myapp.war --runtime-name=abc.war --name=myapp1


The JBoss console/log output will be as following:

18:01:25,995 INFO  [org.jboss.as.repository] (management-handler-thread - 1) JBAS014900: Content added at location /NotBackedUp/Intern_Training/jboss-eap-6.1/standalone/data/content/eb/66cce417ab2bd456e0530deae361abb05f97ec/content
18:01:25,998 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015876: Starting deployment of "myapp1" (runtime-name: "abc.war")
18:01:26,054 INFO  [org.jboss.web] (ServerService Thread Pool -- 64) JBAS018210: Register web context: /abc
18:01:26,173 INFO  [org.jboss.as.server] (management-handler-thread - 1) JBAS018559: Deployed "myapp1" (runtime-name : "abc.war")


Step-2).
======== Modify the "myapp.war" and then deploy it again on the same JBoss with a different "--name" (keep the "--runtime-name" same) as following:
[standalone@localhost:9999 /] deploy /home/jsenshar/myapp.war --runtime-name=abc.war --name=myapp2

Now check the JBoss Console/log, you will notice that JBoss is uploading the content of the application in "data/content" directory.   So here it is expected that JBoss should complaint/throwError that an application with the same "runtime-name" is already registered. 

18:04:14,428 INFO  [org.jboss.as.repository] (management-handler-thread - 6) JBAS014900: Content added at location /NotBackedUp/Intern_Training/jboss-eap-6.1/standalone/data/content/16/df3dd071683f6c188e69e64dd885acc82fab61/content




Actual results:
See Steps to reproduce.


Expected results:

JBoss should wither throw Error when another deployment attempt is made with the same "runtime-name" rather than allowing to upload the new application's content in the "data/content" directory.

Additional info:
$JBOSS_HOME/docs/schema/jboss-as-config_1_3.xsd which states the runtime-name should be unique among the same server group.  

++++++++++++++
        <xs:attribute name="runtime-name" use="required">
            <xs:annotation>
                <xs:documentation>Name by which the deployment will be known within a running server.of the deployment.
                    Does not need to be unique across all deployments in the domain, although it must be unique within
                    an individual server. For example, two different deployments running on different servers in
                    the domain could both have a 'runtime-name' of 'example.war', with one having a 'name'
                    of 'example.war_v1' and another with an 'name' of 'example.war_v2'.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
++++++++++++++

Comment 1 Emmanuel Hugonnet (ehsavoie) 2013-08-01 13:57:01 UTC
According to the Runtime-Name description :
Name by which the deployment should be known within a server's runtime. This would be equivalent to the file name of a deployment file, and would form the basis for such things as default Java Enterprise Edition application and module names. This would typically be the same as 'name', but in some cases users may wish to have two deployments with the same 'runtime-name' (e.g. two versions of "foo.war") both available in the deployment content repository, in which case the deployments would need to have distinct 'name' values but would have the same 'runtime-name'.

So it is not a bug, even if I don't see the use case behind it.

Comment 2 dereed 2013-08-01 17:17:36 UTC
[response to Emmanuel]

Having two deployments with the same runtime-name in the domain content repository, so they can be deployed to different instances, is ok.

Having two deployments with the same runtime name actually deployed to an instance is not (that's the issue here).

Comment 3 dereed 2013-08-01 17:27:16 UTC
A little more detail... The original issue was found in domain mode:

    <deployments>
        <deployment name="test.war.v1" runtime-name="test.war">
            <content sha1="abc..."/>
        </deployment>
        <deployment name="test.war.v2" runtime-name="test.war">
            <content sha1="def..."/>
        </deployment>
    </deployments>

    <server-groups>
        <server-group name="main-server-group" profile="full">
            <deployments>
                <deployment name="test.war.v1" runtime-name="test.war"/>
                <deployment name="test.war.v2" runtime-name="test.war"/>
            </deployments>
        </server-group>
    </server-groups>

The first <deployments> section is correct.  In that section, only "name" must be unique.
But the two entries in <server-group><deployments> is a bug, as runtime-name must be unique there.

The test case listed in the original BZ description is the standalone equivalent of the above configuration, where runtime-name *must* be unique but is isn't being enforced.

Comment 4 Alexey Loubyansky 2013-08-09 12:59:46 UTC
This should be fixed in the domain management, not cli.

Comment 5 JBoss JIRA Server 2013-08-30 07:12:42 UTC
Emmanuel Hugonnet <ehugonne> made a comment on jira WFLY-1972

A little more detail... The original issue was found in domain mode:

    <deployments>
        <deployment name="test.war.v1" runtime-name="test.war">
            <content sha1="abc..."/>
        </deployment>
        <deployment name="test.war.v2" runtime-name="test.war">
            <content sha1="def..."/>
        </deployment>
    </deployments>

    <server-groups>
        <server-group name="main-server-group" profile="full">
            <deployments>
                <deployment name="test.war.v1" runtime-name="test.war"/>
                <deployment name="test.war.v2" runtime-name="test.war"/>
            </deployments>
        </server-group>
    </server-groups>

The first <deployments> section is correct.  In that section, only "name" must be unique.
But the two entries in <server-group><deployments> is a bug, as runtime-name must be unique there.

The test case listed in the original BZ description is the standalone equivalent of the above configuration, where runtime-name *must* be unique but is isn't being enforced.

Comment 8 Petr Kremensky 2013-09-18 13:20:33 UTC
Verified in EAP 6.2.0.ER2.

EAP is now acting as described in comment 2

If user tries to deploy application with already used runtime name:
"There is already a deployment called ${name} with the same runtime name ${runtime-name} on server group ${server-group}"
message is shown.