class PakfireBuilderClient(BuildMixin, PakfireClient):
type = "builder"
- def send_keepalive(self, overload=None):
+ def send_keepalive(self, overload=None, free_space=None):
"""
Sends a little keepalive to the server and
updates the hardware information if the server
# Collect the current loadavg and send it to the hub.
loadavg = ", ".join(("%.2f" % round(l, 2) for l in os.getloadavg()))
- needs_update = self.conn.send_keepalive(loadavg, overload)
+ needs_update = self.conn.send_keepalive(loadavg, overload, free_space)
if needs_update:
log.debug("The hub is requesting an update.")
# Return the number of processes.
return len(self.processes)
+ @property
+ def free_space(self):
+ mp = system.get_mountpoint(BUILD_ROOT)
+
+ return mp.space_left
+
def get_job(self):
"""
Get a build job from the hub.
"""
+ if not self.free_space >= 2 * 1024**3:
+ log.warning(_("Less than 2GB of free space. Cannot request a new job."))
+ return
+
log.info("Requesting a new job from the server...")
# Get some information about this system.
if time.time() - self._last_keepalive < 30:
return
- self.client.send_keepalive(overload=self.has_overload())
+ free_space = self.free_space / 1024**2
+
+ self.client.send_keepalive(
+ overload=self.has_overload(),
+ free_space=free_space,
+ )
self._last_keepalive = time.time()
def remove_finished_builders(self):
return memory
+ def get_mountpoint(self, path):
+ return Mountpoint(path)
+
# Create an instance of this class to only keep it once in memory.
system = System()
class Mountpoints(object):
- def __init__(self, pakfire, root="/"):
- self.pakfire = pakfire
-
+ def __init__(self, root="/"):
self._mountpoints = []
# Scan for all mountpoints on the system.
# If root is not equal to /, we are in a chroot and
# our root must be a mountpoint to count files.
if not root == "/":
- mp = Mountpoint(self.pakfire, "/", root=root)
+ mp = Mountpoint("/", root=root)
self._mountpoints.append(mp)
f = open("/proc/mounts")
else:
mountpoint = os.path.join("/", mountpoint)
- mp = Mountpoint(self.pakfire, mountpoint, root=root)
+ mp = Mountpoint(mountpoint, root=root)
if not mp in self._mountpoints:
self._mountpoints.append(mp)
class Mountpoint(object):
- def __init__(self, pakfire, path, root="/"):
- self.pakfire = pakfire
+ def __init__(self, path, root="/"):
self.path = path
self.root = root
self.filelist = self.load_filelist()
# Get information about the mounted filesystems.
- self.mountpoints = system.Mountpoints(self.pakfire, root=self.pakfire.path)
+ self.mountpoints = system.Mountpoints(self.pakfire.path)
@property
def error_files(self):