remove early-exit from cleanup_nodes that broke dead node cleanup
@@ -875,10 +875,6 @@ class Scaleset(BASE_SCALESET, ORMMixin):
nodes = Node.search_states(scaleset_id=self.scaleset_id)
- if not nodes:
- logging.info("no nodes need updating: %s", self.scaleset_id)
- return False
-
# Nodes do not exists in scalesets but in table due to unknown failure
for node in nodes:
if node.machine_id not in azure_nodes:
@@ -886,13 +882,11 @@ class Scaleset(BASE_SCALESET, ORMMixin):
"no longer in scaleset: %s:%s", self.scaleset_id, node.machine_id
)
node.delete()
- nodes = [x for x in nodes if x.machine_id in azure_nodes]
-
- nodes_to_reset = [x for x in nodes if x.state in NodeState.ready_for_reset()]
- if len(nodes_to_reset) == 0:
- logging.info("No needs are ready for resetting: %s", self.scaleset_id)
- return False
+ existing_nodes = [x for x in nodes if x.machine_id in azure_nodes]
+ nodes_to_reset = [
+ x for x in existing_nodes if x.state in NodeState.ready_for_reset()
+ ]
for node in nodes_to_reset:
if node.delete_requested:
@@ -925,7 +919,7 @@ class Scaleset(BASE_SCALESET, ORMMixin):
except UnableToUpdate:
logging.info("scaleset update already in progress: %s", self.scaleset_id)
- return True
+ return bool(to_reimage) or bool(to_delete)
def _resize_equal(self) -> None:
# NOTE: this is the only place we reset to the 'running' state.
