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): rgmanager-2.0.52-6.el5 How reproducible: Always 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: sha1_addToFile() { declare sha1line="# rgmanager-sha1 $(sha1sum "$1")" echo $sha1line >> "$1" } Adding the following function to /usr/share/cluster/utils/config-utils.sh will fix it: sha1_addToFileXML() { 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 generate_config_file() { 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 fi fi 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: generate_config_file() { 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 else return 0 fi fi 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:
Created attachment 413058 [details] Cluster.conf, tomcat5.conf, server.xml
@Rafael: 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 else return 0 fi 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.
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"
@Sean: sure I did not have any problems with points that were not mentioned
Problem 2) will be fixed; rest is cloned for next update Fixed in upstream at: http://git.fedorahosted.org/git/?p=cluster.git;a=commit;h=5492f5160f1cef50ac5fc38cf184974e587bbfb3
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. http://rhn.redhat.com/errata/RHBA-2011-0134.html