X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f14ce11321e919cc39b878fe9f7847e1a9bb0de3..e2bf56f0a0fa1f6b4fb7b4efc4db5178b074b8ce:/services/nodemanager/arvnodeman/nodelist.py diff --git a/services/nodemanager/arvnodeman/nodelist.py b/services/nodemanager/arvnodeman/nodelist.py index 5b02fde0ce..e06ec83b62 100644 --- a/services/nodemanager/arvnodeman/nodelist.py +++ b/services/nodemanager/arvnodeman/nodelist.py @@ -1,4 +1,7 @@ #!/usr/bin/env python +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 from __future__ import absolute_import, print_function @@ -29,13 +32,19 @@ class ArvadosNodeListMonitorActor(clientactor.RemotePollLoopActor): sinfo_out = subprocess.check_output(["sinfo", "--noheader", "--format=%n %t"]) nodestates = {} for out in sinfo_out.splitlines(): - nodename, state = out.split(" ", 2) - if state in ('alloc', 'comp'): - nodestates[nodename] = 'busy' - elif state == 'idle': - nodestates[nodename] = 'idle' - else: - nodestates[nodename] = 'down' + try: + nodename, state = out.split(" ", 2) + if state in ('alloc', 'alloc*', + 'comp', 'comp*', + 'mix', 'mix*', + 'drng', 'drng*'): + nodestates[nodename] = 'busy' + elif state == 'idle': + nodestates[nodename] = 'idle' + else: + nodestates[nodename] = 'down' + except ValueError: + pass for n in nodelist: if n["slot_number"] and n["hostname"] and n["hostname"] in nodestates: @@ -52,12 +61,22 @@ class CloudNodeListMonitorActor(clientactor.RemotePollLoopActor): nodes, and sends it to subscribers. """ + def __init__(self, client, timer_actor, server_calc, *args, **kwargs): + super(CloudNodeListMonitorActor, self).__init__( + client, timer_actor, *args, **kwargs) + self._calculator = server_calc + def is_common_error(self, exception): - return self._client.is_cloud_exception(exception) + return isinstance(exception, config.CLOUD_ERRORS) def _item_key(self, node): return node.id def _send_request(self): - n = self._client.list_nodes() - return n + nodes = self._client.list_nodes() + for n in nodes: + # Replace with libcloud NodeSize object with compatible + # CloudSizeWrapper object which merges the size info reported from + # the cloud with size information from the configuration file. + n.size = self._calculator.find_size(n.size.id) + return nodes