Add the setup state to the unavailable list (#1731)

* Add the setup state to the unavailable list

* Add the init state to the unavailable list

* Fix integration test

* Wrong import
This commit is contained in:
Teo Voinea
2022-04-01 14:00:25 -04:00
committed by GitHub
parent 20d3df0a11
commit 9cbbf86e36
2 changed files with 4 additions and 2 deletions

View File

@ -32,7 +32,7 @@ import requests
from onefuzz.api import Command, Onefuzz from onefuzz.api import Command, Onefuzz
from onefuzz.backend import ContainerWrapper, wait from onefuzz.backend import ContainerWrapper, wait
from onefuzz.cli import execute_api from onefuzz.cli import execute_api
from onefuzztypes.enums import OS, ContainerType, TaskState, VmState from onefuzztypes.enums import OS, ContainerType, TaskState, VmState, ScalesetState
from onefuzztypes.models import Job, Pool, Repro, Scaleset, Task from onefuzztypes.models import Job, Pool, Repro, Scaleset, Task
from onefuzztypes.primitives import Container, Directory, File, PoolName, Region from onefuzztypes.primitives import Container, Directory, File, PoolName, Region
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
@ -415,6 +415,8 @@ class TestOnefuzz:
task.config.pool is not None task.config.pool is not None
and scaleset.pool_name == task.config.pool.pool_name and scaleset.pool_name == task.config.pool.pool_name
and scaleset.state not in scaleset.state.available() and scaleset.state not in scaleset.state.available()
# not available() does not mean failed
and scaleset.state not in [ScalesetState.init, ScalesetState.setup]
): ):
self.logger.error( self.logger.error(
"task scaleset failed: %s - %s - %s (%s)", "task scaleset failed: %s - %s - %s (%s)",

View File

@ -325,7 +325,7 @@ class ScalesetState(Enum):
@classmethod @classmethod
def available(cls) -> List["ScalesetState"]: def available(cls) -> List["ScalesetState"]:
"""set of states that indicate if it's available for work""" """set of states that indicate if it's available for work"""
unavailable = [cls.shutdown, cls.halt, cls.creation_failed] unavailable = [cls.shutdown, cls.halt, cls.creation_failed, cls.setup, cls.init]
return [x for x in cls if x not in unavailable] return [x for x in cls if x not in unavailable]
@classmethod @classmethod