Bug 734214

Summary: cpsetup tomcat timeout is too short (sometimes)
Product: [Community] Candlepin Reporter: Jesus M. Rodriguez <jesusr>
Component: candlepinAssignee: Jesus M. Rodriguez <jesusr>
Status: CLOSED CURRENTRELEASE QA Contact: John Sefler <jsefler>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 0.5CC: bkearney, jmolet, lzap
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Solaris   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-05-29 19:04:56 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 715031    

Description Jesus M. Rodriguez 2011-08-29 18:38:38 UTC
In some cases the default time out of 5 seconds is too short when waiting for tomcat to restart. Instead of using a hard coded timeout, we should use a more dynamic way of detecting if tomcat has restarted.

Spacewalk had a similar problem in their installer, which they solved.

http://git.fedorahosted.org/git/?p=spacewalk.git;a=blob;f=spacewalk/setup/bin/spacewalk-setup;h=114817f6155637164dc04e8ea203c413de745e24;hb=28be9373d18952ef29b938175ac465a6e7d21b63#l1385

Comment 1 Jesus M. Rodriguez 2011-08-29 18:39:03 UTC
1385 sub wait_for_tomcat {
1386     my $hostname = shift;
1387 
1388     for (my $i = 0; $i < 20; $i++) {
1389         IO::Socket::INET->new(
1390             PeerAddr => 'localhost',
1391             PeerPort => '8009',
1392             Proto    => 'tcp'
1393         ) or last;
1394         sleep 5;
1395     }
1396 
1397     for (my $i = 0; $i < 20; $i++) {
1398         my $retval = system("HEAD http://$hostname/ 2>&1 > /dev/null");
1399         if ($retval) {
1400             sleep 5;
1401         }
1402         else {
1403             return;
1404         }
1405     }
1406     print "Tomcat failed to start properly or the installer ran out of tries.  Please check /var/log/tomcat*/catalina.out for errors.\n";
1407     return;
1408 }

Comment 2 Lukas Zapletal 2011-08-30 11:56:01 UTC
Looks cool. Finally this problem gets solved ;-)

Comment 3 Jesus M. Rodriguez 2011-09-22 20:23:03 UTC
Comment #1 needs to be ported to python and added to cpsetup.

Comment 4 Jesus M. Rodriguez 2011-09-22 21:04:22 UTC
I don't think we can rely on HEAD system call which is provided by
perl-libwww-perl, but we can simulate a HEAD call from within python:

http://docs.python.org/library/httplib.html

from the docs:
>>> import httplib
>>> conn = httplib.HTTPConnection("www.python.org")
>>> conn.request("HEAD","/index.html")
>>> res = conn.getresponse()

Comment 5 Bryan Kearney 2011-10-04 15:49:15 UTC
Fixed in 9d38c154297e760839934fb8333b4e0a4a6a9af4

Comment 7 J.C. Molet 2011-11-28 21:08:00 UTC
VERIFIED, 

candlepin-tomcat6-0.4.27-1.fc14.noarch
candlepin-0.4.27-1.fc14.noarch

Set up candlepin according to: https://fedorahosted.org/candlepin/wiki/Setup  on a slow computer.

running the cpsetup:


[root@localhost ~]# /usr/share/candlepin/cpsetup
Dropping candlepin database
Creating candlepin database
Loading candlepin schema
Writing configuration file
Creating CA private key password
Creating CA private key
Creating CA public key
Creating CA certificate
Waiting for tomcat to restart...
Candlepin has been configured.


The "waiting for tomcat restart" took about 20 seconds (longer than the old 5 second wait) and did not error out.