in src/slurm_plugin/slurm_resources.py [0:0]
def is_state_healthy(self, consider_drain_as_unhealthy, consider_down_as_unhealthy, log_warn_if_unhealthy=True):
"""Check if a slurm node's scheduler state is considered healthy."""
# Check if node is rebooting: if so, the node is healthy
if self.is_rebooting():
return True
# Check to see if node is in DRAINED, ignoring any node currently being replaced or in POWER_DOWN
if self.is_drained() and not self.is_power_down() and consider_drain_as_unhealthy:
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 consider_down_as_unhealthy:
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