=== modified file 'lava_dispatcher/device/master.py'
@@ -65,6 +65,14 @@
Target.android_deployment_data['boot_cmds'] = 'boot_cmds_android'
Target.ubuntu_deployment_data['boot_cmds'] = 'boot_cmds'
+ # used for tarballcache logic to get proper boot_cmds
+ Target.ubuntu_deployment_data['data_type'] = 'ubuntu'
+ Target.oe_deployment_data['data_type'] = 'oe'
+ self.target_map = {
+ 'ubuntu': Target.ubuntu_deployment_data,
+ 'oe': Target.oe_deployment_data,
+ }
+
self.master_ip = None
if config.pre_connect_command:
@@ -124,8 +132,9 @@
self.boot_master_image()
if self.context.job_data.get('health_check', False):
- (boot_tgz, root_tgz) = tarballcache.get_tarballs(
+ (boot_tgz, root_tgz, data) = tarballcache.get_tarballs(
self.context, image, self.scratch_dir, self._generate_tarballs)
+ self.deployment_data = self.target_map[data]
else:
image_file = download_image(image, self.context, self.scratch_dir)
boot_tgz, root_tgz = self._generate_tarballs(image_file)
@@ -171,7 +180,11 @@
tb = traceback.format_exc()
self.sio.write(tb)
raise
- return boot_tgz, root_tgz
+
+ # we need to associate the deployment data with these so that we
+ # can provide the proper boot_cmds later on in the job
+ data = self.deployment_data['data_type']
+ return boot_tgz, root_tgz, data
def target_extract(self, runner, tar_url, dest, timeout=-1, num_retry=5):
decompression_char = ''
=== modified file 'lava_dispatcher/tarballcache.py'
@@ -47,18 +47,25 @@
with _cache_locked(image_url, context.config.lava_cachedir) as cachedir:
boot_tgz = os.path.join(cachedir, 'boot.tgz')
root_tgz = os.path.join(cachedir, 'root.tgz')
+ data_file = os.path.join(cachedir, 'data')
if os.path.exists(boot_tgz) and os.path.exists(root_tgz):
- logging.info('returning cached copies')
- (boot_tgz, root_tgz) = _link(boot_tgz, root_tgz, scratch_dir)
- return (boot_tgz, root_tgz)
+ data = _get_data(cachedir, data_file)
+ if data is not None:
+ logging.info('returning cached copies')
+ (boot_tgz, root_tgz) = _link(boot_tgz, root_tgz, scratch_dir)
+ return (boot_tgz, root_tgz, data)
+ else:
+ logging.info('no cache found for %s' % image_url)
- logging.info('no cache found for %s' % image_url)
+ _clear_cache(boot_tgz, root_tgz, data_file)
image = download_image(image_url, context, cachedir)
- (boot_tgz, root_tgz) = generator(image)
+ (boot_tgz, root_tgz, data) = generator(image)
+ with open(data_file, 'w') as f:
+ f.write(data)
_link(boot_tgz, root_tgz, cachedir)
os.unlink(image)
- return (boot_tgz, root_tgz)
+ return (boot_tgz, root_tgz, data)
def _link(boot_tgz, root_tgz, destdir):
@@ -69,6 +76,25 @@
return (dboot_tgz, droot_tgz)
+def _clear_cache(boot_tgz, root_tgz, data):
+ logging.info('Clearing cache contents')
+ if os.path.exists(boot_tgz):
+ os.unlink(boot_tgz)
+ if os.path.exists(root_tgz):
+ os.unlink(root_tgz)
+ if os.path.exists(data):
+ os.unlink(data)
+
+
+def _get_data(cachedir, data_file):
+ try:
+ with open(data_file, 'r') as f:
+ return f.read()
+ except IOError:
+ logging.warn('No data found for cached tarballs in %s' % cachedir)
+ return None
+
+
@contextlib.contextmanager
def _cache_locked(image_url, cachedir):
cachedir = utils.url_to_cache(image_url, cachedir).replace('.', '-')