Add post build cleanup of tmpfs chroots

The memory tied up in tmpfs filesystems needs to be released
after building packages.

Depends-On: https://review.opendev.org/c/starlingx/tools/+/931220
Closes-Bug: 2081843
Change-Id: I18faedf6ad2e59d20d3db7837b5c3f80ad4261af
Signed-off-by: Scott Little <scott.little@windriver.com>
This commit is contained in:
Scott Little 2024-10-02 15:14:21 -04:00
parent 53a23581da
commit 26fb461ecf

View File

@ -593,7 +593,8 @@ class BuildController():
'build_all': False, 'build_all': False,
'reuse_export': True, 'reuse_export': True,
'dl_reused': False, 'dl_reused': False,
'reuse_shared_repo': True 'reuse_shared_repo': True,
'tmpfs_percentage': DEFAULT_TEMPFS_PERCENTAGE
} }
self.kits = { self.kits = {
'dsc_cache': {}, 'dsc_cache': {},
@ -804,6 +805,7 @@ class BuildController():
def stop(self): def stop(self):
self.attrs['poll_build_status'] = False self.attrs['poll_build_status'] = False
self.req_stop_task() self.req_stop_task()
self.free_tmpfs_chroots()
return self.show_build_stats() return self.show_build_stats()
def get_reused_debs(self): def get_reused_debs(self):
@ -967,7 +969,8 @@ class BuildController():
if 'success' in ret: if 'success' in ret:
logger.debug('Parent chroot is ready to create children chroots') logger.debug('Parent chroot is ready to create children chroots')
extra_args = {'instances': self.attrs['parallel']} extra_args = {'instances': self.attrs['parallel']}
if hasattr(self, 'tmpfs_percentage'): if 'tmpfs_percentage' in self.attrs:
logger.info("tmpfs_percentage = %s" % self.attrs['tmpfs_percentage'])
extra_args['tmpfs_percentage'] = self.attrs['tmpfs_percentage'] extra_args['tmpfs_percentage'] = self.attrs['tmpfs_percentage']
ret_status = req_chroots_action('clonechroot', extra_args) ret_status = req_chroots_action('clonechroot', extra_args)
if not 'success' == ret_status: if not 'success' == ret_status:
@ -977,6 +980,13 @@ class BuildController():
return ret return ret
def free_tmpfs_chroots(self):
ret = req_chroots_action('freetmpfschroots', None)
if 'success' in ret:
logger.debug('Successfully freed tmpfs chroots')
if 'fail' in ret:
logger.debug('Failed to free tmpfs chroots')
def clone_chroots(self): def clone_chroots(self):
ret = req_chroots_action('clonechroot', None) ret = req_chroots_action('clonechroot', None)
if 'success' in ret: if 'success' in ret:
@ -2233,7 +2243,7 @@ if __name__ == "__main__":
if args.refresh_chroots: if args.refresh_chroots:
if build_controller.refresh_chroots() != 'success': if build_controller.refresh_chroots() != 'success':
logger.error("Failed to fresh all the idle chroots") logger.error("Failed to refresh all the idle chroots")
sys.exit(1) sys.exit(1)
else: else:
logger.info("Successfully refreshed all the idle chroots") logger.info("Successfully refreshed all the idle chroots")