Bug 850723

Summary: standalone.conf of jbossas-7/jbosseap-6 does not read node_profile from '/etc/stickshift/resource_limits.conf' at all
Product: OKD Reporter: Nick Tan <missedone>
Component: ContainersAssignee: Bill DeCoste <wdecoste>
Status: CLOSED NOTABUG QA Contact: libra bugs <libra-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 1.xCC: missedone
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-08-25 14:53:26 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 Nick Tan 2012-08-22 08:49:23 UTC
Description of problem:
I created a jboss app on OpenShift Origin, but found that not able to change the jboss JVM settings, since the standalone.conf of jbossas-7/jbosseap-6 does not read node_profile from '/etc/stickshift/resource_limits.conf' at all


Steps to Reproduce:
1. create any one simple jboss app on OpenShift Origin, 
2. start the app, you can see the JVM setting are of 'small' node_profile.
3. then try to modify the node_profile to medium in /etc/stickshift/resource_limits.conf, 
4. restart the jboss app, we will see the JVM setting not change


Additional info:
the original code snippet for reading the node_profile in standalone.conf was:
  resource_limits_file=`readlink -f /etc/stickshift/resource_limits.conf`
  resource_limits_file_name=`basename $resource_limits_file`
  node_profile=`echo ${resource_limits_file_name/*./}`

my workaround are here two options:
### option1:
source $resource_limits_file

### option2:
node_profile=`sed '/^\#/d' /etc/stickshift/resource_limits.conf | grep 'node_profile'  | tail -n 1 | cut -d "=" -f2-`
# set node_profile as 'small' by default, if it not set
if test "x$node_profile" = "x"
then
    node_profile=small
fi
echo "node_profile=$node_profile"

Comment 1 Bill DeCoste 2012-08-23 20:48:16 UTC
What JVM settings are you trying to add/modify?

Comment 2 Bill DeCoste 2012-08-23 22:14:15 UTC
Below are the settings for the small and medium gears. These settings are correct. Are there additional VM settings you need to add?

For small gears:
VM Arguments: -D[Standalone] -Xmx256m -XX:MaxPermSize=128m -XX:+AggressiveOpts -Dorg.apache.tomcat.util.LOW_MEMORY=true -Dorg.jboss.r
esolver.warning=true -Djava.net.preferIPv4Stack=true -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Djboss.node.name=small-judcon.rhcloud.com -Djgroups.bind_addr=127.
10.158.1 -Dorg.jboss.boot.log.file=/var/lib/stickshift/b3c30b333ebd4c07abc7d8e4222e505a/small/jbossas-7/standalone/log/boot.log -Dlogging.configuration=file:/var/lib/stickshi
ft/b3c30b333ebd4c07abc7d8e4222e505a/small/jbossas-7/standalone/configuration/logging.properties

For medium gears:
VM Arguments: -D[Standalone] -Xmx664m -XX:MaxPermSize=128m -XX:+AggressiveOpts -Dorg.apache.tomcat.util.LOW_MEMORY=true -Dorg.jboss.r
esolver.warning=true -Djava.net.preferIPv4Stack=true -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Djboss.node.name=medium-judcon.rhcloud.com -Djgroups.bind_addr=127
.12.127.1 -Dorg.jboss.boot.log.file=/var/lib/stickshift/6c822f1f97b041de972fb19d769b2e45/medium/jbossas-7/standalone/log/boot.log -Dlogging.configuration=file:/var/lib/sticks
hift/6c822f1f97b041de972fb19d769b2e45/medium/jbossas-7/standalone/configuration/logging.properties

Comment 3 Nick Tan 2012-08-24 02:29:08 UTC
hi, Bill

i'm not suck at the JVM settings, my point is i would like to switch between 'small', 'medium', 'large' JVM settings.
from my understanding, by modifying the 'node_profile' in /etc/stickshift/resource_limits.conf can make the tricky (according what I read from the source code), but the problem is no matter what value for 'node_profile' i changed, the 'small' JVM setting was always used, that means the standalone.conf does not read 'node_profile' correctly
so I provided two options to read the 'node_profile' from resource_limits.conf

Comment 4 Bill DeCoste 2012-08-24 02:47:08 UTC
Hi Nick,

OK, I think I see the problem. standalone.conf picks up the value from the link not from the contents of the linked file. If you want to modify the default behavior you should modify the link, not the content of the file (see below). 

I assume you are running OpenShift locally? Either built from source or via LiveCD?

resource_limits_file=`readlink -f /etc/stickshift/resource_limits.conf`
resource_limits_file_name=`basename $resource_limits_file`
node_profile=`echo ${resource_limits_file_name/*./}`
case "$node_profile" in
    micro)
        memory_options="-client -Xmx100m -XX:MaxPermSize=100m -XX:+AggressiveOpts -Dorg.apache.tomcat.util.LOW_MEMORY=true"
    ;;
    small)
        memory_options="-client -Xmx256m -XX:MaxPermSize=128m -XX:+AggressiveOpts -Dorg.apache.tomcat.util.LOW_MEMORY=true"
    ;;
    medium)
        memory_options="-client -Xmx664m -XX:MaxPermSize=128m -XX:+AggressiveOpts -Dorg.apache.tomcat.util.LOW_MEMORY=true"
    ;;
    large)
        memory_options="-Xmx1456m -XX:MaxPermSize=148m -XX:+AggressiveOpts"
    ;;
    exlarge)
        memory_options="-Xmx2888m -XX:MaxPermSize=184m -XX:+AggressiveOpts"
    ;;
    jumbo)
        memory_options="-Xmx5888m -XX:MaxPermSize=256m -XX:+AggressiveOpts"
    ;;
esac

Thanks -Bill

Comment 5 Nick Tan 2012-08-24 04:13:56 UTC
hi, Bill

i build openshift origin from source code (multi-nodes)

where is the link file located? thanks

Comment 6 Bill DeCoste 2012-08-24 14:55:27 UTC
/etc/stickshift/resource_limits.conf is a link. It's linked to one the real file /etc/stickshift/resource_limits.conf.small. If you change the link so that /etc/stickshift/resource_limits.conf points to /etc/stickshift/resource_limits.conf.medium then the standalone.conf will use the medium gear profile settings (i.e. memory)

Comment 7 Nick Tan 2012-08-24 16:20:54 UTC
ah, OK, I see, i should 'man readlink' before, on my OpenShift Origin, the resource_limits.conf is a file, will try link later, thanks very much.

Comment 8 Bill DeCoste 2012-08-24 16:27:43 UTC
Please let me know if moving the link works for you so I can close the bug. Thanks

Comment 9 Nick Tan 2012-08-25 04:10:32 UTC
Thanks, Bill

yes, it works now after I created the /etc/stickshift/resource_limits.conf.medium, /etc/stickshift/resource_limits.conf.small, and created link file /etc/stickshift/resource_limits.conf point to /etc/stickshift/resource_limits.conf.medium.

but I'm just wondering why not create these conf profiles and link file by default? (in my case, the resource_limits.conf is a plain file not a link at all)

Comment 10 Bill DeCoste 2012-08-25 14:53:26 UTC
This allows us to create predefined profile settings and easily switch between then for the default gear size. You can also control the JVM settings by using the rhc --gear-size option when you create you application. 

I'm going to close this bug, but please reach out to me at wdecoste on on IRC if you have any other questions.