pkgbuilder: Stop chroot sessions before refreshing chroots

The build option 'refresh_chroots' will fail if one of the
chroot's flag is busy and the session is active.
This commit forces to stop all the sessions of chroots and
set the flag to idle to make refresh chroots works.
This commit requires rebuilding the pkgbuilder container.

Test Plan:
Pass: build-pkgs -a --parallel 10 --refresh_chroots
      build-pkgs -c -p <package> --refresh_chroots

Story: 2008846
Task: 46973

Signed-off-by: Haiqing Bai <haiqing.bai@windriver.com>
Change-Id: I4eff4c7d316e8c747d829460526f1f01258062bc
This commit is contained in:
Haiqing Bai 2022-12-01 15:14:34 +08:00
parent 771c7d5382
commit 3c47de92db

View File

@ -382,7 +382,6 @@ class Debbuilder:
def refresh_chroots(self, request_form): def refresh_chroots(self, request_form):
''' '''
Refresh all chroots with the backup 'clean' chroot Refresh all chroots with the backup 'clean' chroot
if all of them are free
''' '''
response = check_request(request_form, ['user', 'project']) response = check_request(request_form, ['user', 'project'])
if response: if response:
@ -392,10 +391,13 @@ class Debbuilder:
dst_chroots = self.chroots_pool.get_idle() dst_chroots = self.chroots_pool.get_idle()
if not dst_chroots: if not dst_chroots:
self.logger.error('Failed to refresh chroots for some chroots are busy') self.logger.warning('Some chroots are busy')
response['status'] = 'fail' self.logger.warning('Force to refresh chroots')
response['msg'] = 'Some chroots are busy' self.stop_task(request_form)
return response self.chroots_pool.release_all()
# Stop all schroot sessions
subprocess.call('schroot -a -e', shell=True)
backup_chroot = None backup_chroot = None
user_dir = os.path.join(STORE_ROOT, user, project) user_dir = os.path.join(STORE_ROOT, user, project)