Bug 704948

Summary: beaker-proxy init script is half broken
Product: [Retired] Beaker Reporter: Marco Grigull <mgrigull>
Component: lab controllerAssignee: Bill Peck <bpeck>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 0.6CC: bpeck, dcallagh, mcsontos, rmancy, stl
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-06-03 05:31:04 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Marco Grigull 2011-05-16 05:42:34 UTC
Description of problem:
'/etc/init.d/beaker-proxy restart' fails with python stacktrace

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

How reproducible:
100%

Steps to Reproduce:
1. '/etc/init.d/beaker-proxy restart'
2.
3.
  
Actual results:
python stacktrace displayed, no service restart

Expected results:
It should work the same way 'service beaker-proxy restart' does

Additional info:
admins and automated process control tools expecting to track the service in question via the aforementioned method will be impeded by this fault.  The service may also fail to start properly on reboot (unverified but suspected).

Comment 1 Bill Peck 2011-05-16 13:02:21 UTC
Can you provide the stack trace here? 

Thanks

Comment 2 Marco Grigull 2011-05-16 13:16:02 UTC
[root@lab ~]# /etc/init.d/beaker-proxy restart
Stopping beaker-proxy:                                     [FAILED]
Starting beaker-proxy: Traceback (most recent call last):
  File "/usr/bin/beaker-proxy", line 8, in ?
    sys.exit(
  File "/usr/lib/python2.4/site-packages/bkr/labcontroller/main.py", line 128, in main
    foreground=False)
  File "/usr/lib/python2.4/site-packages/kobo/process.py", line 56, in daemonize
    os.chdir(daemon_start_dir)
OSError: [Errno 13] Permission denied: '.'
Frame daemonize in /usr/lib/python2.4/site-packages/kobo/process.py at line 56
<CODE>
      49             sys.exit(0)
      50     except OSError, ex:
      51         sys.stderr.write("fork #1 failed: (%d) %s\n" % (ex.errno, ex.strerror))
      52         sys.exit(1)
      53 
      54     # decouple from parent environment
      55     os.setsid()
-->   56     os.chdir(daemon_start_dir)
      57     os.umask(0)
      58 
      59     # second fork
      60     try:
      61         pid = os.fork()
      62         if pid > 0:
</CODE>
<LOCALS>
                args = <ERROR WHILE CONVERTING VALUE TO STRING>
             cmdline = None
      daemon_err_log = /dev/null
         daemon_func = <function main_loop at 0x10074f50>
      daemon_out_log = /dev/null
     daemon_pid_file = /var/run/beaker-lab-controller/beaker-proxy.pid
    daemon_start_dir = .
                   f = <closed file '/var/run/beaker-lab-controller/beaker-proxy.pid', mode 'r' at 0x100790a8>
                  fn = /proc/4904/cmdline
              kwargs = {'foreground': False, 'conf': {'USERNAME': 'host/lab.rhts.englab.bne.redhat.com', 'KRB_SERVICE': 'HTTP', 'ARCHIVE_BASEPATH': '/var/www/html/beaker-logs', 'CACHE': True, 'ARCHIVE_SERVER': 'http://beaker-devel.app.eng.bos.redhat.com/beaker-logs', 'ARCHIVE_RSYNC': 'rsync://lab_controllers.eng.bos.redhat.com/beaker-logs', 'RSYNC_FLAGS': '-ar --password-file /etc/beaker/rsync.secret', 'PASSWORD': 'redHat', 'HUB_URL': 'https://beaker.engineering.redhat.com', 'AUTH_METHOD': 'password', 'KRB_REALM': 'DOMAIN.COM'}}
                 pid = 4904
</LOCALS>
Frame main in /usr/lib/python2.4/site-packages/bkr/labcontroller/main.py at line 128
<CODE>
     121     
     122     if opts.foreground:
     123         main_loop(conf=conf, foreground=True)
     124     else:
     125         daemonize(main_loop, 
     126                   daemon_pid_file=pid_file,
     127                   conf=conf, 
-->  128                   foreground=False)
     129 
     130 if __name__ == '__main__':
     131     main()
</CODE>
<LOCALS>
                args = []
                conf = {'USERNAME': 'host/lab.rhts.englab.bne.redhat.com', 'KRB_SERVICE': 'HTTP', 'ARCHIVE_BASEPATH': '/var/www/html/beaker-logs', 'CACHE': True, 'ARCHIVE_SERVER': 'http://beaker-devel.app.eng.bos.redhat.com/beaker-logs', 'ARCHIVE_RSYNC': 'rsync://lab_controllers.eng.bos.redhat.com/beaker-logs', 'RSYNC_FLAGS': '-ar --password-file /etc/beaker/rsync.secret', 'PASSWORD': '##scrubbed##', 'HUB_URL': 'https://beaker.engineering.redhat.com', 'AUTH_METHOD': 'password', 'KRB_REALM': 'DOMAIN.COM'}
              config = /etc/beaker/proxy.conf
                opts = {'pid_file': None, 'foreground': False, 'config': None}
              parser = <optparse.OptionParser instance at 0x2ac5d10cd2d8>
            pid_file = /var/run/beaker-lab-controller/beaker-proxy.pid
</LOCALS>
Frame ? in /usr/bin/beaker-proxy at line 8
<CODE>
       1 #!/usr/bin/python
       2 # EASY-INSTALL-ENTRY-SCRIPT: 'bkr.labcontroller==0.6.10','console_scripts','beaker-proxy'
       3 __requires__ = 'bkr.labcontroller==0.6.10'
       4 import sys
       5 from pkg_resources import load_entry_point
       6 
       7 if __name__ == '__main__':
-->    8     sys.exit(
       9         load_entry_point('bkr.labcontroller==0.6.10', 'console_scripts', 'beaker-proxy')()
      10     )
</CODE>
<LOCALS>
        __builtins__ = <module '__builtin__' (built-in)>
             __doc__ = None
            __file__ = /usr/bin/beaker-proxy
            __name__ = __main__
        __requires__ = bkr.labcontroller==0.6.10
    load_entry_point = <function load_entry_point at 0x2ac5cdf467d0>
                 sys = <module 'sys' (built-in)>
</LOCALS>

                                                           [  OK  ]
[root@lab ~]#

Comment 3 Bill Peck 2011-05-16 13:54:03 UTC
Ahh!  Thank you for the traceback, Its failing because it can't chdir to where it was started from (maybe /root?).  I brought this up with Daniel Mach before and thought he had fixed it in kobo but maybe we don't have the newest version installed.  I'll track this down.

as a work around you restart the service from / or /tmp and it will not traceback.

Comment 4 Marco Grigull 2011-05-20 01:37:03 UTC
Beakerd init is also half broken

[root@beaker-01 ~]# /etc/init.d/beakerd start
Starting beakerd: Traceback (most recent call last):
  File "/usr/bin/beakerd", line 8, in ?
    sys.exit(
  File "/usr/lib/python2.4/site-packages/bkr/server/tools/beakerd.py", line 639, in main
    daemonize(schedule, daemon_pid_file=pid_file)
  File "/usr/lib/python2.4/site-packages/bkr/server/tools/beakerd.py", line 584, in daemonize
    os.chdir(daemon_start_dir)
OSError: [Errno 13] Permission denied: '.'
                                                           [  OK  ]
[root@beaker-01 ~]# service beakerd start
Starting beakerd:                                          [  OK  ]

Comment 5 Bill Peck 2011-05-25 18:11:46 UTC
I have updated the code to make sure it chdir to / instead of .

But I'm not sure you should be running services via /etc/init.d.  Running the following works perfectly fine:

[root@lab-devel ~]# service beaker-proxy restart
Stopping beaker-proxy:                                     [  OK  ]
Starting beaker-proxy:                                     [  OK  ]


Changes pushed to gerrit