My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 3209: Root can not start Gerrit if multiple container.javaOptions values is used
1 person starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----


Sign in to add a comment
 
Reported by mav...@cpqd.com.br, Feb 25, 2015
Affected Version:

Verified on 2.9.2 and 2.10

What steps will reproduce the problem?

1. Set multiple values for container.javaOption in gerrit.config

Ex:
[container]
	user = gerrit
	javaHome = /usr/java/latest/jre
	heapLimit = 2g
	javaOptions = -XX:+PrintGC
	javaOptions = -XX:+PrintGCDetails
	javaOptions = -XX:+PrintGCDateStamps
	javaOptions = -Xloggc:/home/gerrit/gerrit/logs/java/gc_java_log

2. Try to start Gerrit with the root user

What is the expected output? What do you see instead?

Gerrit should start but the start fail with some Java errors.

Please provide any additional information below.

The problem is in the bin/gerrit.sh script:

  if test $UID = 0 -a -n "$GERRIT_USER" ; then
    touch "$GERRIT_PID"
    chown $GERRIT_USER "$GERRIT_PID"
    su - $GERRIT_USER -s /bin/sh -c "
      JAVA='$JAVA' ; export JAVA ;
      $RUN_EXEC $RUN_Arg1 '$RUN_Arg2' $RUN_Arg3 $RUN_ARGS </dev/null >/dev/null 2>&1 &
      PID=\$! ;
      disown ;
      echo \$PID >\"$GERRIT_PID\""
  else
    $RUN_EXEC $RUN_Arg1 "$RUN_Arg2" $RUN_Arg3 $RUN_ARGS </dev/null >/dev/null 2>&1 &
    PID=$!
    type disown >/dev/null 2>&1 && disown
    echo $PID >"$GERRIT_PID"
  fi

The "su - $GERRIT_USER..." command using double quotes in "-c" parameter expands the $RUN_ARGS variable to:

-XX:+PrintGC
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-Xloggc:/home/gerrit/gerrit/logs/java/gc_java_log

Instead of:

-XX:+PrintGC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:/home/gerrit/gerrit/logs/java/gc_java_log

Note 1:

If just one javaOptions line is used the start works just fine:

Ex:
[container]
	user = gerrit
	javaHome = /usr/java/latest/jre
	heapLimit = 2g
	javaOptions = -XX:+PrintGC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:/home/gerrit/gerrit/logs/java/gc_java_log

Note 2:

The documentation (https://gerrit.cpqd.com.br/Documentation/config-gerrit.html#container) says that multiple container.javaOptions values can be used:

"... If multiple values are configured, they are passed in order on the command line, separated by spaces."
Sign in to add a comment

Powered by Google Project Hosting