Karaf
  1. Karaf
  2. KARAF-1241

admin script does not pass on JAVA_OPTS to instance

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.2.5
    • Fix Version/s: 2.2.6, 3.0.0
    • Component/s: None
    • Labels:
      None
    • Environment:

      apache-karaf-2.2.5.tar.gz

      Description

      The JAVA_OPTS set in the bin/admin script are passed on to the admin process but then when the admin process kicks off a new Karaf instance, the options get lost. For example, when setting the max JVM memory to 1024M as follows:

      [janstey@duffman apache-karaf-2.2.5]$ export JAVA_MAX_MEM=1024M
      

      You can see that the default of 512M is still used for the Karaf instance:

      [janstey@duffman apache-karaf-2.2.5]$ ./bin/admin start root
      [org.apache.karaf.admin.internal.InstanceImpl] : Starting instance root with command: /opt/jdk1.6.0_23/jre/bin/java -server -Xmx512M -Dcom.sun.management.jmxremote  -Djava.util.logging.config.file="/opt/fuse/apache-karaf-2.2.5/etc/java.util.logging.properties" -Djava.endorsed.dirs="/opt/jdk1.6.0_23/jre/jre/lib/endorsed:/opt/jdk1.6.0_23/jre/lib/endorsed:/opt/fuse/apache-karaf-2.2.5/lib/endorsed" -Djava.ext.dirs="/opt/jdk1.6.0_23/jre/jre/lib/ext:/opt/jdk1.6.0_23/jre/lib/ext:/opt/fuse/apache-karaf-2.2.5/lib/ext" -Dkaraf.home="/opt/fuse/apache-karaf-2.2.5" -Dkaraf.base="/opt/fuse/apache-karaf-2.2.5" -Dkaraf.startLocalConsole=false -Dkaraf.startRemoteShell=true -classpath /opt/fuse/apache-karaf-2.2.5/lib/karaf.jar:/opt/fuse/apache-karaf-2.2.5/lib/karaf-jaas-boot.jar org.apache.karaf.main.Main
      

      Attaching a fix shortly.

      1. KARAF-1241.patch
        2 kB
        Jonathan Anstey

        Activity

        Hide
        Jonathan Anstey added a comment -

        Ah OK, makes sense. Thanks for looking at this JB.

        IMO it isn't very intuitive to users though. One would expect the JAVA_MIN_MEM/JAVA_MAX_MEM environment variables to be used since they are there in the script (like in bin/karaf). To not confuse users we should remove those variables altogether or just change the script comment to be different from bin/karaf (since the behaviour is different). Maybe something like:

        Index: assemblies/apache-karaf/src/main/filtered-resources/bin/admin
        ===================================================================
        --- assemblies/apache-karaf/src/main/filtered-resources/bin/admin	(revision 1294797)
        +++ assemblies/apache-karaf/src/main/filtered-resources/bin/admin	(working copy)
        @@ -29,6 +29,9 @@
         
         #
         # Check/Set up some easily accessible MIN/MAX params for JVM mem usage
        +# 
        +# Note that these memory settings will not propagate to the child instance. You 
        +# will need to use the admin:change-opts command for that.
         #
         if [ "x$JAVA_MIN_MEM" = "x" ]; then
             JAVA_MIN_MEM=128M
        

        WDYT?

        Show
        Jonathan Anstey added a comment - Ah OK, makes sense. Thanks for looking at this JB. IMO it isn't very intuitive to users though. One would expect the JAVA_MIN_MEM/JAVA_MAX_MEM environment variables to be used since they are there in the script (like in bin/karaf). To not confuse users we should remove those variables altogether or just change the script comment to be different from bin/karaf (since the behaviour is different). Maybe something like: Index: assemblies/apache-karaf/src/main/filtered-resources/bin/admin =================================================================== --- assemblies/apache-karaf/src/main/filtered-resources/bin/admin (revision 1294797) +++ assemblies/apache-karaf/src/main/filtered-resources/bin/admin (working copy) @@ -29,6 +29,9 @@ # # Check/Set up some easily accessible MIN/MAX params for JVM mem usage +# +# Note that these memory settings will not propagate to the child instance. You +# will need to use the admin:change-opts command for that. # if [ "x$JAVA_MIN_MEM" = "x" ]; then JAVA_MIN_MEM=128M WDYT?
        Hide
        Jean-Baptiste Onofré added a comment -

        I don't think it's a good idea. The child instances are isolated from the master one, or from the system properties.

        To pass the memory setup, you have to use admin:change-opts.

        For instance:

        karaf@root> admin:create test
        karaf@root> admin:change-opts test "-Xmx1024"

        bin/admin start test
        [org.apache.karaf.admin.internal.InstanceImpl] : Starting instance test with command: /opt/jdk/1.6.0_26/jre/bin/java -Xmx1024m -Djava.util.logging.config.file="/home/jbonofre/apach......

        So it looks good to me.

        The args passed via the admin script are ignored, and it's what we expect.

        Show
        Jean-Baptiste Onofré added a comment - I don't think it's a good idea. The child instances are isolated from the master one, or from the system properties. To pass the memory setup, you have to use admin:change-opts. For instance: karaf@root> admin:create test karaf@root> admin:change-opts test "-Xmx1024" bin/admin start test [org.apache.karaf.admin.internal.InstanceImpl] : Starting instance test with command: /opt/jdk/1.6.0_26/jre/bin/java -Xmx1024m -Djava.util.logging.config.file="/home/jbonofre/apach...... So it looks good to me. The args passed via the admin script are ignored, and it's what we expect.
        Hide
        Jonathan Anstey added a comment -

        Patch to fix this on karaf-2.2.x branch.

        Show
        Jonathan Anstey added a comment - Patch to fix this on karaf-2.2.x branch.

          People

          • Assignee:
            Jean-Baptiste Onofré
            Reporter:
            Jonathan Anstey
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development