in src/slurm_plugin/slurm_resources.py [0:0]
def is_state_healthy(self, terminate_drain_nodes, terminate_down_nodes, log_warn_if_unhealthy=True):
"""Check if a slurm node's scheduler state is considered healthy."""
# Check to see if node is in DRAINED, ignoring any node currently being replaced
if self.is_drained() and terminate_drain_nodes:
if log_warn_if_unhealthy:
logger.warning("Node state check: node %s in DRAINED, node state: %s", self, self.state_string)
return False
# Check to see if node is in DOWN, ignoring any node currently being replaced
elif self.is_down() and terminate_down_nodes:
if not self.is_nodeaddr_set():
# Silently handle failed to launch dynamic node to clean up normal logging
logger.debug("Node state check: node %s in DOWN, node state: %s", self, self.state_string)
else:
if log_warn_if_unhealthy:
logger.warning("Node state check: node %s in DOWN, node state: %s", self, self.state_string)
return False
return True