From 70b6cf867247647490cce49d5a029c135b8a9b86 Mon Sep 17 00:00:00 2001 From: Hongyi Wang Date: Tue, 10 Dec 2019 14:22:32 -0800 Subject: [PATCH] Handle allocation while machine type not specify --- ducktape/cluster/node_container.py | 13 ++++++------- ducktape/cluster/remoteaccount.py | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ducktape/cluster/node_container.py b/ducktape/cluster/node_container.py index fd937fb73..41550bc70 100644 --- a/ducktape/cluster/node_container.py +++ b/ducktape/cluster/node_container.py @@ -14,6 +14,7 @@ from six import iteritems from operator import attrgetter +from ducktape.cluster.remoteaccount import MachineType class NodeNotPresentError(Exception): @@ -184,10 +185,9 @@ def satisfy(avail_node, req_node): """ if req_node.machine_type is None: return True - elif avail_node.machine_type is None or \ - avail_node.machine_type.cpu_core < req_node.machine_type.cpu_core or \ - avail_node.machine_type.mem_size_gb < req_node.machine_type.mem_size_gb or \ - avail_node.machine_type.disk_size_gb < req_node.machine_type.disk_size_gb: + if avail_node.machine_type.cpu_core < req_node.machine_type.cpu_core or \ + avail_node.machine_type.mem_size_gb < req_node.machine_type.mem_size_gb or \ + avail_node.machine_type.disk_size_gb < req_node.machine_type.disk_size_gb: return False for d_name, d_size in req_node.machine_type.additional_disks.items(): if avail_node.machine_type.additional_disks.get(d_name, 0) < d_size: @@ -197,7 +197,7 @@ def satisfy(avail_node, req_node): @staticmethod def sort(nodes, reverse=False): """ - Return sorted list of nodes based on machine_type. If any the machine + Return sorted list of nodes based on machine_type. """ sorted_nodes = [] type_based_nodes = [] @@ -208,8 +208,7 @@ def sort(nodes, reverse=False): type_based_nodes.append(node) sorted_nodes.extend(sorted(type_based_nodes, key=attrgetter('machine_type.cpu_core', 'machine_type.mem_size_gb', - 'machine_type.disk_size_gb', - 'machine_type.additional_disks'))) + 'machine_type.disk_size_gb', 'machine_type.additional_disks'))) return list(reversed(sorted_nodes)) if reverse else sorted_nodes def clone(self): diff --git a/ducktape/cluster/remoteaccount.py b/ducktape/cluster/remoteaccount.py index a6324bb42..bc574c9dd 100644 --- a/ducktape/cluster/remoteaccount.py +++ b/ducktape/cluster/remoteaccount.py @@ -140,7 +140,7 @@ def __init__(self, ssh_config, externally_routable_ip=None, logger=None, is_type self.os = None self._ssh_client = None self._sftp_client = None - self.type = self._get_machine_type() if is_type_based else None + self.type = self._get_machine_type() if is_type_based else MachineType() @property def operating_system(self):