From 08d1ea03df852e9468076d76a7f58a4ed51b1555 Mon Sep 17 00:00:00 2001 From: bmc-msft <41130664+bmc-msft@users.noreply.github.com> Date: Tue, 22 Sep 2020 13:15:31 -0400 Subject: [PATCH] finish scaleset state refactor (#19) * finish scaleset state refactor --- .../__app__/daily_events/__init__.py | 6 ++++++ .../__app__/scaleset_events/__init__.py | 2 -- .../__app__/scheduled_events/__init__.py | 19 ++----------------- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/api-service/__app__/daily_events/__init__.py b/src/api-service/__app__/daily_events/__init__.py index 8e82adfa99..ec9c6d6fe4 100644 --- a/src/api-service/__app__/daily_events/__init__.py +++ b/src/api-service/__app__/daily_events/__init__.py @@ -8,6 +8,7 @@ import azure.functions as func from onefuzztypes.enums import VmState +from ..onefuzzlib.pools import Scaleset from ..onefuzzlib.proxy import Proxy @@ -17,3 +18,8 @@ def main(mytimer: func.TimerRequest) -> None: # noqa: F841 logging.info("stopping proxy") proxy.state = VmState.stopping proxy.save() + + scalesets = Scaleset.search() + for scaleset in scalesets: + logging.info("updating scaleset configs: %s", scaleset.scaleset_id) + scaleset.update_configs() diff --git a/src/api-service/__app__/scaleset_events/__init__.py b/src/api-service/__app__/scaleset_events/__init__.py index 4ad9ae89a8..2a86e8215c 100644 --- a/src/api-service/__app__/scaleset_events/__init__.py +++ b/src/api-service/__app__/scaleset_events/__init__.py @@ -30,8 +30,6 @@ def process_scaleset(scaleset: Scaleset) -> None: getattr(scaleset, scaleset.state.name)() return - scaleset.update_configs() - def main(mytimer: func.TimerRequest, dashboard: func.Out[str]) -> None: # noqa: F841 scalesets = Scaleset.search() diff --git a/src/api-service/__app__/scheduled_events/__init__.py b/src/api-service/__app__/scheduled_events/__init__.py index 927483c216..13e33e162e 100644 --- a/src/api-service/__app__/scheduled_events/__init__.py +++ b/src/api-service/__app__/scheduled_events/__init__.py @@ -6,32 +6,17 @@ import logging import azure.functions as func -from onefuzztypes.enums import ( - JobState, - NodeState, - PoolState, - ScalesetState, - TaskState, - VmState, -) +from onefuzztypes.enums import JobState, NodeState, PoolState, TaskState, VmState from ..onefuzzlib.dashboard import get_event from ..onefuzzlib.jobs import Job -from ..onefuzzlib.pools import Node, Pool, Scaleset +from ..onefuzzlib.pools import Node, Pool from ..onefuzzlib.proxy import Proxy from ..onefuzzlib.repro import Repro from ..onefuzzlib.tasks.main import Task def main(mytimer: func.TimerRequest, dashboard: func.Out[str]) -> None: # noqa: F841 - scalesets = Scaleset.search() - scalesets_needs_work = ScalesetState.needs_work() - for scaleset in scalesets: - logging.info("queueing scaleset updates: %s", scaleset.scaleset_id) - scaleset.queue(method=scaleset.update_configs) - if scaleset.state in scalesets_needs_work: - scaleset.queue() - proxies = Proxy.search_states(states=VmState.needs_work()) for proxy in proxies: logging.info("requeueing update proxy vm: %s", proxy.region)