Ejemplo n.º 1
0
    def check_lookaside_cache_usage(self):
        """Check usage of lookaside cache, and fail if used"""
        git_uri, git_commit = self.koji_build['source'].split('#')

        source = GitSource('git',
                           git_uri,
                           provider_params={'git_commit': git_commit})
        source_path = source.get()
        sources_cache_file = os.path.join(source_path, 'sources')

        uses_cache = False
        if os.path.exists(sources_cache_file):
            if os.path.getsize(sources_cache_file) > 0:
                uses_cache = True

        source.remove_workdir()

        if not uses_cache:
            return

        allowlist_cache_yaml = self._get_cache_allowlist()
        should_raise = True

        if allowlist_cache_yaml:
            build_component = self.koji_build['package_name']
            build_task = self.koji_build['extra']['container_koji_task_id']
            task_info = self.session.getTaskInfo(build_task, request=True)
            build_target = task_info['request'][1]

            for allowed in allowlist_cache_yaml:
                if allowed['component'] != build_component:
                    continue

                for target in allowed['targets']:
                    if re.match(target, build_target):
                        self.log.debug(
                            'target "%s" for component "%s" has allowed using '
                            'lookaside cache', build_target, build_component)

                        should_raise = False
                        break

                if not should_raise:
                    break

        if should_raise:
            raise RuntimeError(
                'Repository is using lookaside cache, which is not allowed '
                'for source container builds')
Ejemplo n.º 2
0
    def check_lookaside_cache_usage(self):
        """Check usage of lookaside cache, and fail if used"""
        git_uri, git_commit = self.koji_build['source'].split('#')

        source = GitSource('git',
                           git_uri,
                           provider_params={'git_commit': git_commit})
        source_path = source.get()
        sources_cache_file = os.path.join(source_path, 'sources')

        if os.path.exists(sources_cache_file):
            if os.path.getsize(sources_cache_file) > 0:
                raise RuntimeError(
                    'Repository is using lookaside cache, which is not allowed '
                    'for source container builds')
        source.remove_workdir()