diff --git a/src/api-service/__app__/onefuzzlib/tasks/config.py b/src/api-service/__app__/onefuzzlib/tasks/config.py index 532c06c9e..75253f967 100644 --- a/src/api-service/__app__/onefuzzlib/tasks/config.py +++ b/src/api-service/__app__/onefuzzlib/tasks/config.py @@ -18,6 +18,7 @@ from ..azure.containers import blob_exists, container_exists, get_container_sas_ from ..azure.creds import get_instance_id from ..azure.queue import get_queue_sas from ..azure.storage import StorageType +from ..workers.pools import Pool from .defs import TASK_DEFINITIONS LOGGER = logging.getLogger("onefuzz") @@ -143,25 +144,24 @@ def check_config(config: TaskConfig) -> None: raise TaskConfigError("missing supervisor_exe") if config.vm: - if not check_val(definition.vm.compare, definition.vm.value, config.vm.count): - err = "invalid vm count: expected %s %d, got %s" % ( - definition.vm.compare, - definition.vm.value, - config.vm.count, - ) - LOGGER.error(err) - raise TaskConfigError(err) - elif config.pool: - if not check_val(definition.vm.compare, definition.vm.value, config.pool.count): - err = "invalid vm count: expected %s %d, got %s" % ( - definition.vm.compare, - definition.vm.value, - config.pool.count, - ) - LOGGER.error(err) - raise TaskConfigError(err) - else: - raise TaskConfigError("either the vm or pool must be specified") + err = "specifying task config vm is no longer supported" + raise TaskConfigError(err) + + if not config.pool: + raise TaskConfigError("pool must be specified") + + if not check_val(definition.vm.compare, definition.vm.value, config.pool.count): + err = "invalid vm count: expected %s %d, got %s" % ( + definition.vm.compare, + definition.vm.value, + config.pool.count, + ) + LOGGER.error(err) + raise TaskConfigError(err) + + pool = Pool.get_by_name(config.pool.pool_name) + if not isinstance(pool, Pool): + raise TaskConfigError(f"invalid pool: {config.pool.pool_name}") check_target_exe(config, definition)