mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-22 06:18:06 +00:00
ignore nodes already scheduled for re-imaging in outdated check (#341)
If a node is already scheduled to be reimaged/deleted, we should not bother checking if it's outdated.
This commit is contained in:
@ -46,6 +46,7 @@ from .updates import queue_update
|
||||
A = TypeVar("A", bound="ORMMixin")
|
||||
|
||||
QUERY_VALUE_TYPES = Union[
|
||||
List[bool],
|
||||
List[int],
|
||||
List[str],
|
||||
List[UUID],
|
||||
@ -135,6 +136,12 @@ def build_filters(
|
||||
field_name = field
|
||||
|
||||
parts: Optional[List[str]] = None
|
||||
if isinstance(values[0], bool):
|
||||
parts = []
|
||||
for x in values:
|
||||
if not isinstance(x, bool):
|
||||
raise TypeError("unexpected type")
|
||||
parts.append("%s eq %s" % (field_name, str(x).lower))
|
||||
if isinstance(values[0], int):
|
||||
parts = []
|
||||
for x in values:
|
||||
|
@ -99,6 +99,7 @@ class Node(BASE_NODE, ORMMixin):
|
||||
scaleset_id: Optional[UUID] = None,
|
||||
states: Optional[List[NodeState]] = None,
|
||||
pool_name: Optional[str] = None,
|
||||
exclude_update_scheduled: bool = False,
|
||||
) -> List["Node"]:
|
||||
query: QueryFilter = {}
|
||||
if scaleset_id:
|
||||
@ -108,6 +109,10 @@ class Node(BASE_NODE, ORMMixin):
|
||||
if pool_name:
|
||||
query["pool_name"] = [pool_name]
|
||||
|
||||
if exclude_update_scheduled:
|
||||
query["reimage_requested"] = [False]
|
||||
query["delete_requested"] = [False]
|
||||
|
||||
# azure table query always return false when the column does not exist
|
||||
# We write the query this way to allow us to get the nodes where the
|
||||
# version is not defined as well as the nodes with a mismatched version
|
||||
@ -116,7 +121,7 @@ class Node(BASE_NODE, ORMMixin):
|
||||
|
||||
@classmethod
|
||||
def mark_outdated_nodes(cls) -> None:
|
||||
outdated = cls.search_outdated()
|
||||
outdated = cls.search_outdated(exclude_update_scheduled=True)
|
||||
for node in outdated:
|
||||
logging.info(
|
||||
"node is outdated: %s - node_version:%s api_version:%s",
|
||||
|
Reference in New Issue
Block a user