Skip to content

Commit

Permalink
Handle allocation while machine type not specify
Browse files Browse the repository at this point in the history
  • Loading branch information
whynick1 committed Dec 10, 2019
1 parent 0076773 commit 70b6cf8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions ducktape/cluster/node_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from six import iteritems
from operator import attrgetter
from ducktape.cluster.remoteaccount import MachineType


class NodeNotPresentError(Exception):
Expand Down Expand Up @@ -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:
Expand All @@ -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 = []
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion ducktape/cluster/remoteaccount.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 70b6cf8

Please sign in to comment.