summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
9a4f3ac)
This introduces locking for the commonly used vagrant functions in
vmtools because vagrant fails when another vagrant command is
already running.
import resource
import sys
import tarfile
import resource
import sys
import tarfile
import traceback
import time
import requests
import traceback
import time
import requests
+def force_halt_build():
+ """Halt the currently running Vagrant VM, to be called from a Timer"""
+ logging.error(_('Force halting build after timeout!'))
+ vm = vmtools.get_build_vm('builder')
+ vm.halt()
+
+
def parse_commandline():
"""Parse the command line. Returns options, parser."""
def parse_commandline():
"""Parse the command line. Returns options, parser."""
first = True
for build in app.builds:
first = True
for build in app.builds:
+ if options.server: # enable watchdog timer
+ timer = threading.Timer(7200, force_halt_build)
+ timer.start()
+ else:
+ timer = None
+
wikilog = None
build_starttime = common.get_wiki_timestamp()
tools_version_log = ''
wikilog = None
build_starttime = common.get_wiki_timestamp()
tools_version_log = ''
except Exception as e:
logging.error("Error while attempting to publish build log: %s" % e)
except Exception as e:
logging.error("Error while attempting to publish build log: %s" % e)
+ if timer:
+ timer.cancel() # kill the watchdog timer
+
for app in build_succeeded:
logging.info("success: %s" % (app.id))
for app in build_succeeded:
logging.info("success: %s" % (app.id))
from logging import getLogger
from fdroidserver import _
from logging import getLogger
from fdroidserver import _
+import threading
+
+lock = threading.Lock()
logger = getLogger('fdroidserver-vmtools')
logger = getLogger('fdroidserver-vmtools')
This is intended to be a hypervisor independant, fault tolerant
wrapper around the vagrant functions we use.
"""
This is intended to be a hypervisor independant, fault tolerant
wrapper around the vagrant functions we use.
"""
def __init__(self, srvdir):
"""Create new server class.
"""
def __init__(self, srvdir):
"""Create new server class.
"""
self.vgrnt = vagrant.Vagrant(root=srvdir, out_cm=vagrant.stdout_cm, err_cm=vagrant.stdout_cm)
def up(self, provision=True):
self.vgrnt = vagrant.Vagrant(root=srvdir, out_cm=vagrant.stdout_cm, err_cm=vagrant.stdout_cm)
def up(self, provision=True):
- try:
- self.vgrnt.up(provision=provision)
- self.srvuuid = self._vagrant_fetch_uuid()
- except subprocess.CalledProcessError as e:
- raise FDroidBuildVmException("could not bring up vm '%s'" % self.srvname) from e
+ global lock
+ with lock:
+ try:
+ self.vgrnt.up(provision=provision)
+ self.srvuuid = self._vagrant_fetch_uuid()
+ except subprocess.CalledProcessError as e:
+ raise FDroidBuildVmException("could not bring up vm '%s'" % self.srvname) from e
- logger.info('suspending buildserver')
- try:
- self.vgrnt.suspend()
- except subprocess.CalledProcessError as e:
- raise FDroidBuildVmException("could not suspend vm '%s'" % self.srvname) from e
+ global lock
+ with lock:
+ logger.info('suspending buildserver')
+ try:
+ self.vgrnt.suspend()
+ except subprocess.CalledProcessError as e:
+ raise FDroidBuildVmException("could not suspend vm '%s'" % self.srvname) from e
- self.vgrnt.halt(force=True)
+ global lock
+ with lock:
+ self.vgrnt.halt(force=True)
def destroy(self):
"""Remove every trace of this VM from the system.
def destroy(self):
"""Remove every trace of this VM from the system.