Example #1
0
    def get_vm(self) -> VM:
        task = Task.get_by_task_id(self.task_id)
        if isinstance(task, Error):
            raise Exception("previously existing task missing: %s" % self.task_id)

        vm_config = task.get_repro_vm_config()
        if vm_config is None:
            # if using a pool without any scalesets defined yet, use reasonable defaults
            if task.os not in DEFAULT_OS:
                raise NotImplementedError("unsupported OS for repro %s" % task.os)

            vm_config = TaskVm(
                region=get_base_region(), sku=DEFAULT_SKU, image=DEFAULT_OS[task.os]
            )

        if self.auth is None:
            raise Exception("missing auth")

        return VM(
            name=self.vm_id,
            region=vm_config.region,
            sku=vm_config.sku,
            image=vm_config.image,
            auth=self.auth,
        )
Example #2
0
    def get_repro_vm_config(self) -> Union[TaskVm, None]:
        if self.config.vm:
            return self.config.vm

        if self.config.pool is None:
            raise Exception("either pool or vm must be specified: %s" %
                            self.task_id)

        pool = Pool.get_by_name(self.config.pool.pool_name)
        if isinstance(pool, Error):
            logging.info("unable to find pool from task: %s", self.task_id)
            return None

        for scaleset in Scaleset.search_by_pool(self.config.pool.pool_name):
            return TaskVm(
                region=scaleset.region,
                sku=scaleset.vm_sku,
                image=scaleset.image,
            )

        logging.warning("no scalesets are defined for task: %s:%s",
                        self.job_id, self.task_id)
        return None