Bug 1233991 - Creation and group association of bundle fails with IllegalArgumentException: Token did not result in valid file
Summary: Creation and group association of bundle fails with IllegalArgumentException:...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: JBoss Operations Network
Classification: JBoss
Component: Provisioning
Version: JON 3.3.1
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: CR01
: JON 3.3.3
Assignee: Michael Burman
QA Contact: Sunil Kondkar
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-06-20 00:18 UTC by Larry O'Leary
Modified: 2019-08-15 04:44 UTC (History)
4 users (show)

Fixed In Version:
Clone Of:
: 1251503 (view as bug list)
Environment:
Last Closed: 2015-07-30 16:43:42 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
CreateBundle_SuccessMsg (51.87 KB, image/png)
2015-07-27 15:29 UTC, Sunil Kondkar
no flags Details
CreateBundle_Summary (44.97 KB, image/png)
2015-07-27 15:29 UTC, Sunil Kondkar
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1251503 0 high CLOSED Creation and group association of bundle fails with IllegalArgumentException: Token did not result in valid file when de... 2021-02-22 00:41:40 UTC
Red Hat Bugzilla 1252142 0 urgent CLOSED Creation and group association of bundle fails with timeout followed by IllegalArgumentException: Token did not result i... 2021-02-22 00:41:40 UTC
Red Hat Knowledge Base (Solution) 1487393 0 None None None Never
Red Hat Product Errata RHSA-2015:1525 0 normal SHIPPED_LIVE Moderate: Red Hat JBoss Operations Network 3.3.3 update 2015-07-30 20:41:08 UTC

Internal Links: 1251503 1252142

Description Larry O'Leary 2015-06-20 00:18:59 UTC
Description of problem:
A user with the _Create Bundle In Group_ permission is unable to create a bundle and associate it with a bundle group when the bundle archive file is larger then 30 MB. 

    ERROR [org.jboss.as.ejb3.invocation] (http-/0.0.0.0:7080-6) JBAS014134: EJB Invocation failed on component BundleManagerBean for method public abstract org.rhq.core.domain.bundle.BundleVersion org.rhq.enterprise.server.bundle.BundleManagerLocal.createInitialBundleVersionViaToken(org.rhq.core.domain.auth.Subject,int[],java.lang.String) throws java.lang.Exception: javax.ejb.EJBException: java.lang.IllegalArgumentException: Token did not result in valid file [/tmp/upload__2700a40a_14e0df9cb34__8000_00000014.tmp]
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInNoTx(CMTTxInterceptor.java:215) [jboss-as-ejb3-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInNoTx(CMTTxInterceptor.java:261) [jboss-as-ejb3-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
        ...
        at org.rhq.enterprise.server.bundle.BundleManagerLocal$$$view80.createInitialBundleVersionViaToken(Unknown Source) [rhq-server.jar:4.12.0.JON330GA]
        at org.rhq.coregui.server.gwt.BundleGWTServiceImpl.createInitialBundleVersionViaToken(BundleGWTServiceImpl.java:117)
        ...
    Caused by: java.lang.IllegalArgumentException: Token did not result in valid file [/tmp/upload__2700a40a_14e0df9cb34__8000_00000014.tmp]
        at org.rhq.enterprise.server.bundle.BundleManagerBean.createInitialBundleVersionViaToken(BundleManagerBean.java:2671) [rhq-server.jar:4.12.0.JON330GA]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_75]
        ...

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

How reproducible:
Always

Steps to Reproduce:
1.  Install, configure and start JBoss ON 3.3 system.
2.  Build a bundle archive that is at least 80 MB in size.

    ~~~
tmpDir="`mktemp -d`"

cat >"${tmpDir}"/deploy.xml <<EOF
<?xml version="1.0"?>
<project name="largeFile"
         default="main"
         xmlns:rhq="antlib:org.rhq.bundle">
  <target name="main" />

  <rhq:bundle name="Large File Test Bundle"
              version="1.0"
              description="A sample bundle consisting of a single large file">
    <rhq:deployment-unit name="files"
                         compliance="filesAndDirectories">
EOF

mkdir "${tmpDir}"/files
for file in {001..001}; do
    echo "This is File #${file}." > "${tmpDir}/files/file-${file}.txt"
    dd if=/dev/urandom of="${tmpDir}/files/file-${file}.bin" bs=8M count=10
    echo '      <rhq:file name="files/file-'"${file}"'.txt" destinationFile="files/file-'"${file}"'.txt" replace="true" />' >> "${tmpDir}"/deploy.xml
    echo '      <rhq:file name="files/file-'"${file}"'.bin" destinationFile="files/file-'"${file}"'.bin" replace="true" />' >> "${tmpDir}"/deploy.xml
done

cat >>"${tmpDir}"/deploy.xml <<EOF
    </rhq:deployment-unit>
  </rhq:bundle>
</project>
EOF
(cd "${tmpDir}" && zip -r /tmp/large-bundle.zip .)
rm -rf "${tmpDir}"
ls -al /tmp/large-bundle.zip
    ~~~
    
3.  Create a bundle group:

    *   *Name:* `Test01 - Bundle Group`

4.  Create a new user role:

    *   *Permissions:*
        *   *Name:* `Test01 - Bundle Deployer Role`
        *   *Resource Permissions:*
            *   *Inventory:* _Write_
            *   *Control:* _Write_
            *   *Create Child Resources:* _Write_
        *   *Bundle Permissions:*
            *   *Create Bundle In Group:* _Yes_
            *   *Delete Bundle From Group:* _Yes_
            *   *Deploy Bundle To Group:* _Yes_
    *   *Resource Groups:*
        *   *Assigned Resource Groups:* _DynaGroup - Groups by platform ( Linux )_
    *   *Bundle Groups:*
        *   *Assigned Resource Groups:* _Test01 - Bundle Deployer Role_

5.  Create a new user:

    *   *Username:* `TestUser01`
    *   *Password:* `TestUser01`
    *   *First Name:* `Test`
    *   *Last Name:* `User01`
    *   *Email Address:* `testuser01`
    *   *Assigned Roles:* _Test01 - Bundle Deployer Role_
    
6.  Sign-in as _TestUser01_.
7.  Create new bundle using _/tmp/large-bundle.zip_ and assign it to the _Test01 - Bundle Group_ bundle group.

Actual results:
Clicking _Next_ after adding _Test01 - Bundle Group_ to the assigned bundle group list results in a failure message being written at the bottom of the bundle creation dialog:

[1434759019246] javax.ejb.EJBException:java.lang.IllegalArgumentException: Token did not result in valid file [/tmp/upload__2700a40a_14e0df9cb34__8000_00000014.tmp] -> java.lang.IllegalArgumentException:Token did not result in valid file [/tmp/upload__2700a40a_14e0df9cb34__8000_00000014.tmp]

server.log also includes the error with a very long stack trace:

    INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/coregui]] (http-/0.0.0.0:7080-6) org.rhq.coregui.CoreGUI BundleDistributionFileUploadServlet: file was uploaded: large-bundle.zip
    ERROR [org.jboss.as.ejb3.invocation] (http-/0.0.0.0:7080-6) JBAS014134: EJB Invocation failed on component BundleManagerBean for method public abstract org.rhq.core.domain.bundle.BundleVersion org.rhq.enterprise.server.bundle.BundleManagerLocal.createInitialBundleVersionViaToken(org.rhq.core.domain.auth.Subject,int[],java.lang.String) throws java.lang.Exception: javax.ejb.EJBException: java.lang.IllegalArgumentException: Token did not result in valid file [/tmp/upload__2700a40a_14e0df9cb34__8000_00000014.tmp]
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInNoTx(CMTTxInterceptor.java:215) [jboss-as-ejb3-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
        at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInNoTx(CMTTxInterceptor.java:261) [jboss-as-ejb3-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
        ...
        at org.rhq.enterprise.server.bundle.BundleManagerLocal$$$view80.createInitialBundleVersionViaToken(Unknown Source) [rhq-server.jar:4.12.0.JON330GA]
        at org.rhq.coregui.server.gwt.BundleGWTServiceImpl.createInitialBundleVersionViaToken(BundleGWTServiceImpl.java:117)
        ...
    Caused by: java.lang.IllegalArgumentException: Token did not result in valid file [/tmp/upload__2700a40a_14e0df9cb34__8000_00000014.tmp]
        at org.rhq.enterprise.server.bundle.BundleManagerBean.createInitialBundleVersionViaToken(BundleManagerBean.java:2671) [rhq-server.jar:4.12.0.JON330GA]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_75]
        ...
Expected results:
The bundle should be successfully created and no error/warning is displayed or logged in server.log.

Additional info:
If the file is smaller, this error does not occur. This would lead me to believe that the issue has something to do with streaming the file/contents or some type of time interval that results in the temporary file being deleted.

Also, this seems to be permission related. For example, rhqadmin is able to perform the exact same steps without any error. 

TestUser01 is also able to successfully create the bundle if the bundle is created using the recipe file instead of uploading the archive. In other words, instead of using the "upload" option on the first page of the bundle wizard you select "Recipe" and upload the deploy.xml, all works fine.

Comment 1 Larry O'Leary 2015-06-20 00:55:38 UTC
Actually, this does not seem to have anything to do with file size. Even a 15K bundle archive fails in the same manner.

Comment 2 Michael Burman 2015-07-13 11:28:35 UTC
It works as rhqadmin because the same method is not called - it would cause the same error in this case.

Comment 3 Michael Burman 2015-07-13 13:12:18 UTC
Right, the issue is in createBundle(BundleManagerBean:256), where we check for the user rights and check if they have the right to create a bundle or create a bundle for the group.

However, selecting the group happens after the bundle has been uploaded.. so an empty list is sent to the method and it fails. I'll need to ask around a bit what has been the intention of this - I doubt this has ever worked.

Comment 4 Michael Burman 2015-07-14 08:44:41 UTC
Fixed in the master:

commit d7d9c5b6f971b7d495a94ba9fbf1b2905a3c60ac
Author: Michael Burman <miburman>
Date:   Tue Jul 14 11:44:00 2015 +0300

    [BZ 1233991] Fix the viaToken method by fetching the file from correct temp-directory

Comment 6 Simeon Pinder 2015-07-24 06:19:54 UTC
Available for test with following build:
 https://brewweb.devel.redhat.com/buildinfo?buildID=448923
   *Note: jon-server-patch-3.3.0.GA.zip maps to CR01 build of
   jon-server-3.3.0.GA-update-03.zip.

Comment 7 Sunil Kondkar 2015-07-27 15:27:39 UTC
Verified on Version :3.3.0.GA Update 03 Build Number :	edc324f:119e8f4

Followed the steps and verified that the bundle is created successfully by user 'TestUser01' without any error in UI or server.log.

Please refer the attached screenshots.

Comment 8 Sunil Kondkar 2015-07-27 15:29:07 UTC
Created attachment 1056659 [details]
CreateBundle_SuccessMsg

Comment 9 Sunil Kondkar 2015-07-27 15:29:49 UTC
Created attachment 1056660 [details]
CreateBundle_Summary

Comment 11 errata-xmlrpc 2015-07-30 16:43:42 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2015-1525.html


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