diff options
author | Lars Wirzenius <liw@liw.fi> | 2020-04-09 18:59:38 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2020-04-09 18:59:38 +0300 |
commit | 840300655a0bab67c2bfe8243578ee10deb3c822 (patch) | |
tree | 188a7a3a00a21ee4f519cc6bc5e469886a3bc6c2 /contractor | |
parent | 44f50e884d5a4e14c404bf0412b996aa4f3c351c (diff) | |
download | ick-contractor-840300655a0bab67c2bfe8243578ee10deb3c822.tar.gz |
Fix: shut down worker cleanly at end
So that workspace disk gets synced and unmounted cleanly. Otherwise we
lose data there.
Diffstat (limited to 'contractor')
-rwxr-xr-x | contractor | 25 |
1 files changed, 19 insertions, 6 deletions
@@ -63,7 +63,7 @@ class ContractorApplication(cliapp.Application): # This might fail. We ignore the failure. self.verbose('stopping worker') - m.stop_worker() + m.kill_worker() self.verbose( 'uploading image to worker: {}'.format(bs.worker_image())) @@ -99,7 +99,6 @@ class ContractorApplication(cliapp.Application): self.error('build failed') sys.exit(1) - # This might fail. We ignore the failure. self.verbose('stopping worker') m.stop_worker() @@ -235,10 +234,20 @@ class Manager: ['virsh', '-c', 'qemu:///system'] + argv, quiet=True) - def stop_worker(self): + def kill_worker(self): self.virsh(['destroy', 'worker']) self.virsh(['undefine', 'worker']) + def stop_worker(self): + self.virsh(['shutdown', 'worker']) + while True: + er = self.virsh(['list', '--name']) + if er.failed(): + break + if er.stdout.strip() == b'': + break + time.sleep(2) + def upload_worker_image(self, filename): return rsync(filename, '{}:{}'.format(self._target, WORKER_IMG)) @@ -368,19 +377,23 @@ class Manager: return er def save_helper(self, saved_workspace): + print('find before mount') + self.ssh(['sudo', 'find', '/mnt/.']) + er = self.mount(WS_DEV) if er.failed(): return er + print('find after mount') + self.ssh(['sudo', 'find', '/mnt/.']) + if not os.path.exists(saved_workspace): os.makedirs(saved_workspace) - er = rsync( + return rsync( '{}:/mnt/.'.format(self._target), '{}/.'.format(saved_workspace)) - return er - def kpartx(self, options): er = self.ssh(['sudo', 'kpartx', options, TEMP_IMG]) if er.failed(): |