diff --git a/buildman/jobutil/buildjob.py b/buildman/jobutil/buildjob.py index fcf5dcfef..4d85a76c1 100644 --- a/buildman/jobutil/buildjob.py +++ b/buildman/jobutil/buildjob.py @@ -98,17 +98,19 @@ class BuildJob(object): # For each cache comment, find a child image that matches the command. for cache_command in cache_commands: full_command = '["/bin/sh", "-c", "%s"]' % cache_command - current_image = model.find_child_image(repository, current_image, full_command) + current_image = model.find_child_image(repo_build.repository, current_image, full_command) if current_image is None: return None + logger.debug('Found cached image %s for comment %s', current_image.id, full_command) + # Find a tag associated with the image, if any. # TODO(jschorr): We should just return the image ID instead of a parent tag, OR we should # make this more efficient. for tag in model.list_repository_tags(repo_namespace, repo_name): tag_image = tag.image ancestor_index = '/%s/' % current_image.id - if ancestor_index in tag_image.ancestors: + if ancestor_index in tag_image.ancestors or tag_image.id == current_image.id: return tag.name return None