Merge "builder: don't use DibImageFile to construct dib image path"

This commit is contained in:
Zuul 2022-02-05 18:09:36 +00:00 committed by Gerrit Code Review
commit 4f52386611
1 changed files with 9 additions and 6 deletions

View File

@ -789,13 +789,15 @@ class BuildWorker(BaseWorker):
:raises: BuilderError if we failed to execute the build command. :raises: BuilderError if we failed to execute the build command.
''' '''
base = "-".join([diskimage.name, build_id]) base = "-".join([diskimage.name, build_id])
image_file = DibImageFile(base) image_filename = Path(self._config.images_dir) / base
filename = image_file.to_path(self._config.images_dir, False)
env = os.environ.copy() env = os.environ.copy()
env['DIB_RELEASE'] = diskimage.release env['DIB_RELEASE'] = diskimage.release
env['DIB_IMAGE_NAME'] = diskimage.name env['DIB_IMAGE_NAME'] = diskimage.name
env['DIB_IMAGE_FILENAME'] = filename # This is just the basename. DIB may create multiple images
# here based on img_types; each will produce a final output
# file image_filename.<type>
env['DIB_IMAGE_FILENAME'] = image_filename
# Note we use a reference to the nodepool config here so # Note we use a reference to the nodepool config here so
# that whenever the config is updated we get up to date # that whenever the config is updated we get up to date
@ -820,7 +822,7 @@ class BuildWorker(BaseWorker):
cmd = ('%s -x -t %s --checksum --no-tmpfs %s -o %s %s' % cmd = ('%s -x -t %s --checksum --no-tmpfs %s -o %s %s' %
(dib_cmd, img_types, qemu_img_options, (dib_cmd, img_types, qemu_img_options,
filename, img_elements)) image_filename, img_elements))
self._pruneBuildLogs(diskimage.name) self._pruneBuildLogs(diskimage.name)
log_fn = self._getBuildLog(diskimage.name, build_id) log_fn = self._getBuildLog(diskimage.name, build_id)
@ -957,9 +959,10 @@ class BuildWorker(BaseWorker):
# purposes of watching if we've added too much stuff # purposes of watching if we've added too much stuff
# into the image. Note that st_blocks is defined as # into the image. Note that st_blocks is defined as
# 512-byte blocks by stat(2) # 512-byte blocks by stat(2)
size = os.stat("%s.%s" % (filename, ext)).st_blocks * 512 size = os.stat("%s.%s" %
(image_filename, ext)).st_blocks * 512
self.log.debug("%s created image %s.%s (size: %d) " % self.log.debug("%s created image %s.%s (size: %d) " %
(diskimage.name, filename, ext, size)) (diskimage.name, image_filename, ext, size))
pipeline.gauge(key, size) pipeline.gauge(key, size)
if self._statsd: if self._statsd: