update pools before nodes or scalesets (#503)

This commit is contained in:
bmc-msft
2021-02-04 13:26:19 -05:00
committed by GitHub
parent e0cd3d535b
commit 1adee4ea83

View File

@ -28,6 +28,17 @@ def process_scaleset(scaleset: Scaleset) -> None:
def main(mytimer: func.TimerRequest, dashboard: func.Out[str]) -> None: # noqa: F841 def main(mytimer: func.TimerRequest, dashboard: func.Out[str]) -> None: # noqa: F841
# NOTE: Update pools first, such that scalesets impacted by pool updates
# (such as shutdown or resize) happen during this iteration `timer_worker`
# rather than the following iteration.
pools = Pool.search()
for pool in pools:
if pool.state in PoolState.needs_work():
logging.info("update pool: %s (%s)", pool.pool_id, pool.name)
process_state_updates(pool)
elif pool.state in PoolState.available() and pool.autoscale:
autoscale_pool(pool)
Node.mark_outdated_nodes() Node.mark_outdated_nodes()
nodes = Node.search_states(states=NodeState.needs_work()) nodes = Node.search_states(states=NodeState.needs_work())
for node in nodes: for node in nodes:
@ -38,14 +49,6 @@ def main(mytimer: func.TimerRequest, dashboard: func.Out[str]) -> None: # noqa:
for scaleset in scalesets: for scaleset in scalesets:
process_scaleset(scaleset) process_scaleset(scaleset)
pools = Pool.search()
for pool in pools:
if pool.state in PoolState.needs_work():
logging.info("update pool: %s (%s)", pool.pool_id, pool.name)
process_state_updates(pool)
elif pool.state in PoolState.available() and pool.autoscale:
autoscale_pool(pool)
events = get_events() events = get_events()
if events: if events:
dashboard.set(events) dashboard.set(events)