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

update nodes and scalesets in a consistent order #512

Merged
merged 4 commits into from
Feb 5, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/api-service/__app__/timer_workers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def main(mytimer: func.TimerRequest, dashboard: func.Out[str]) -> None: # noqa:
# 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():
Expand All @@ -42,13 +43,17 @@ def main(mytimer: func.TimerRequest, dashboard: func.Out[str]) -> None: # noqa:
autoscale_pool(pool)

Node.mark_outdated_nodes()
# ensure nodes are updated in a consistent order, which is needed for
# autoscaling of pools
bmc-msft marked this conversation as resolved.
Show resolved Hide resolved
nodes = Node.search_states(states=NodeState.needs_work())
for node in nodes:
for node in sorted(nodes, key=lambda x: x.machine_id):
logging.info("update node: %s", node.machine_id)
process_state_updates(node)

scalesets = Scaleset.search()
for scaleset in scalesets:
# ensure scalesets are updated in a consistent order, which is needed for
# autoscaling of pools
for scaleset in sorted(scalesets, key=lambda x: x.scaleset_id):
process_scaleset(scaleset)

events = get_events()
Expand Down