Bug 591003 - Errors in resource script tomcat-5.sh, part of rgmanager
Errors in resource script tomcat-5.sh, part of rgmanager
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: rgmanager (Show other bugs)
i686 Linux
low Severity medium
: rc
: ---
Assigned To: Marek Grac
Cluster QE
Depends On:
Blocks: 593721 614127 614130 637802
  Show dependency treegraph
Reported: 2010-05-11 03:37 EDT by Rafael
Modified: 2011-01-13 18:26 EST (History)
4 users (show)

See Also:
Fixed In Version: rgmanager-2.0.52-6.18.el5
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 593721 637802 (view as bug list)
Last Closed: 2011-01-13 18:26:11 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Cluster.conf, tomcat5.conf, server.xml (1.54 KB, application/x-gzip)
2010-05-11 03:39 EDT, Rafael
no flags Details

  None (edit)
Description Rafael 2010-05-11 03:37:02 EDT
Description of problem:

Errors in the file /usr/share/cluster/tomcat-5.sh resource script, part of rgmanager, that leaves the script unusable.

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


How reproducible:


Steps to Reproduce:
1. Use the attached /etc/cluster/cluster.conf

2. Use the attached /etc/tomcat5/tomcat5.conf

3. Use the attached /etc/tomcat5/server.xml

4.- start cluster services cman and rgmanager

service cman start
service rgmanager start

5.- Use "rg_test" to enable the Artifactory01 service

rg_test test /etc/cluster/cluster.conf start service Artifactory01

Actual results:

1.- "rg_test" says the Service is started, when it doesn't. There are no java processess running on the system

2.- Checking /etc/cluster/tomcat-5/tomcat-5:Artifactory01/logs/catalina.out the problem is due to a problem with the "su" invocation line at /usr/share/cluster/tomcat-5.sh resource script:

su "$TOMCAT_USER" -c "$JAVA_HOME/bin/java" $JAVA_OPTS $OCF_RESKEY_catalina_options \
                -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \
                -Dcatalina.base="$TOMCAT_gen_catalina_base" \
                -Dcatalina.home="$CATALINA_HOME" \
                -Djava.io.tmpdir="$CATALINA_TMPDIR" \
                org.apache.catalina.startup.Bootstrap "$@" start \
                >> "$TOMCAT_gen_catalina_base"/logs/catalina.out 2>&1 &

Changing it to the following it is fixed:

 su "$TOMCAT_USER"  -c " \"$JAVA_HOME/bin/java\" $JAVA_OPTS $OCF_RESKEY_catalina_options \
                -Djava.endorsed.dirs=\"$JAVA_ENDORSED_DIRS\" -classpath \"$CLASSPATH\" \
                -Dcatalina.base=\"$TOMCAT_gen_catalina_base\" \
                -Dcatalina.home=\"$CATALINA_HOME\" \
                -Djava.io.tmpdir=\"$CATALINA_TMPDIR\" \
                org.apache.catalina.startup.Bootstrap \"$@\" start " \
                >> "$TOMCAT_gen_catalina_base"/logs/catalina.out 2>&1 &

3.- There are errors in the parsing of the generated server.xml file in catalina.out  ue to its usage of commented lines in the "sha1_addToFile" function defined in the /usr/share/cluster/utils/config-utils.sh file:

        declare sha1line="# rgmanager-sha1 $(sha1sum "$1")"
        echo $sha1line >> "$1"

Adding the following function to /usr/share/cluster/utils/config-utils.sh will fix it:

        declare sha1line="<!--\n# rgmanager-sha1 $(sha1sum "$1") \n-->"
        echo -e $sha1line >> "$1"

Also it is necessary to change the line of /usr/share/cluster/tomcat-5.sh

        sha1_addToFile "$generated_file"

to the following:

        sha1_addToFileXML "$generated_file"

4.- Changing the the file /etc/tomcat5/server.xml causes the tomcat-5.sh resource script re-generate its own server.xml file located at /etc/cluster/tomcat-5/tomcat-5:Artifactory01/conf/server.xml, but the regeneration concatenates the contents with the previous file causing more parsing errors in catalina.out . This is due to the "generate_config_file" function located in /usr/share/cluster/tomcat-5.sh

	declare original_file="$1"
	declare generated_file="$2"
	declare ip_addresses="$3"

	if [ -f "$generated_file" ]; then
		sha1_verify "$generated_file"
		if [ $? -ne 0 ]; then
			clog_check_sha1 $CLOG_FAILED
			return 0

	clog_generate_config $CLOG_INIT "$original_file" "$generated_file"

#	generate_configTemplate "$generated_file" "$original_file"
	$(dirname $0)/utils/tomcat-parse-config.pl $ip_addresses < "$original_file" >> "$generated_file"

        sha1_addToFile "$generated_file"
	clog_generate_config $CLOG_SUCCEED "$original_file" "$generated_file"
	return 0;

Changing it to the following will fix it:

	declare original_file="$1"
	declare generated_file="$2"
	declare ip_addresses="$3"

	if [ -f "$generated_file" ]; then
		sha1_verify "$generated_file"
		if [ $? -ne 0 ]; then
			clog_check_sha1 $CLOG_FAILED
			return 0

	clog_generate_config $CLOG_INIT "$original_file" "$generated_file"

#	generate_configTemplate "$generated_file" "$original_file"
	$(dirname $0)/utils/tomcat-parse-config.pl $ip_addresses < "$original_file" > "$generated_file"

        sha1_addToFileXML "$generated_file"
	clog_generate_config $CLOG_SUCCEED "$original_file" "$generated_file"
	return 0;

Expected results:

1.- Detection of Tomcat not starting. In this case we used "rg_test", so it's a minot bug

2.- No errors, Tomcat started

3.- No parsing errors in catalina.out

4.- No parsing errors in catalina.out

Additional info:
Comment 1 Rafael 2010-05-11 03:39:15 EDT
Created attachment 413058 [details]
Cluster.conf, tomcat5.conf, server.xml
Comment 3 Marek Grac 2010-07-30 05:08:42 EDT

Thanks for really complex report. Few comments after first tests:

ad 3) if I will use sha1_addToXML & sha1_verify -> in current situation there is no chance that they will match (there are additional lines with <!-- & -->

ad 4) I'm not sure if I correctly understand:

sha1_verify "$generated_file"
if [ $? -ne 0 ]; then
   clog_check_sha1 $CLOG_FAILED
   return 0

what was the reason to change? In original if sha1 won't match (result 1) then configuration file was changed and we should not touch it. If it match original then we wish to create a new configuration file which will include changes from original config file.
Comment 4 Sean Lee 2010-08-17 21:27:11 EDT
2) Even though there is no error initially and the service appears to be started, tomcat never actually starts. Catalina.out will show the following error:

su: invalid option -- D
Try `su --help' for more information.

The solution posted by OP is correct. Su expects the following as one argument:

"$JAVA_HOME/bin/java $JAVA_OPTS $OCF_RESKEY_catalina_options \
-Djava.endorsed.dirs=$JAVA_ENDORSED_DIRS -classpath $CLASSPATH \
-Dcatalina.base=$TOMCAT_gen_catalina_base \
-Dcatalina.home=$CATALINA_HOME \
-Djava.io.tmpdir=$CATALINA_TMPDIR \
org.apache.catalina.startup.Bootstrap $@ start"
Comment 5 Marek Grac 2010-09-02 10:04:58 EDT
@Sean: sure I did not have any problems with points that were not mentioned
Comment 6 Marek Grac 2010-09-27 09:39:08 EDT
Problem 2) will be fixed; rest is cloned for next update

Fixed in upstream at:

Comment 8 errata-xmlrpc 2011-01-13 18:26:11 EST
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.


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