Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
finish scaleset state refactor (#19)
Browse files Browse the repository at this point in the history
* finish scaleset state refactor
  • Loading branch information
bmc-msft authored Sep 22, 2020
1 parent a28538a commit 08d1ea0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
6 changes: 6 additions & 0 deletions src/api-service/__app__/daily_events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import azure.functions as func
from onefuzztypes.enums import VmState

from ..onefuzzlib.pools import Scaleset
from ..onefuzzlib.proxy import Proxy


Expand All @@ -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()
2 changes: 0 additions & 2 deletions src/api-service/__app__/scaleset_events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
19 changes: 2 additions & 17 deletions src/api-service/__app__/scheduled_events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 08d1ea0

Please sign in to comment.