Skip to content

Commit

Permalink
feature: mixed disk drive layouts
Browse files Browse the repository at this point in the history
Provision mixed disk drive layouts when specifying `--num-disks` and
`--disk-size` multiple times.

fixes: SUSE#652
Signed-off-by: Moritz Röhrich <[email protected]>
  • Loading branch information
m-ildefons committed Aug 3, 2022
1 parent 56928b2 commit fed323a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
8 changes: 4 additions & 4 deletions sesdev/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ def common_create_options(func):
help='Number of virtual CPUs for the VMs'),
click.option('--ram', default=None, type=int,
help='Amount of RAM for each VM in gigabytes'),
click.option('--disk-size', default=None, type=int,
click.option('--disk-size', default=None, type=int, multiple=True,
help='Size in gigabytes of storage disks (used by OSDs)'),
click.option('--num-disks', default=None, type=int,
click.option('--num-disks', default=None, type=int, multiple=True,
help='Number of storage disks in OSD nodes'),
click.option('--single-node/--no-single-node', default=False,
help='Deploy a single node cluster. Overrides --roles'),
Expand Down Expand Up @@ -478,13 +478,13 @@ def _gen_settings_dict(
settings_dict['explicit_ram'] = False

if num_disks is not None:
settings_dict['num_disks'] = num_disks
settings_dict['num_disks'] = list(num_disks)
settings_dict['explicit_num_disks'] = True
else:
settings_dict['explicit_num_disks'] = False

if disk_size is not None:
settings_dict['disk_size'] = disk_size
settings_dict['disk_size'] = list(disk_size)

if bluestore is not None:
if bluestore:
Expand Down
2 changes: 2 additions & 0 deletions seslib/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,8 @@ class Constant():

ZYPPER_PRIO_ELEVATED = 50

DEFAULT_DISK_SIZE = 12 # in GiB

@classmethod
def init_path_to_qa(cls, full_path_to_sesdev_executable):
if full_path_to_sesdev_executable.startswith('/usr'):
Expand Down
23 changes: 14 additions & 9 deletions seslib/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def __set_up_make_check(self):
self.settings.override('single_node', True)
self.settings.override('roles', Constant.ROLES_DEFAULT_BY_VERSION['makecheck'])
if not self.settings.explicit_num_disks:
self.settings.override('num_disks', 0)
self.settings.override('num_disks', [0])
self.settings.override('explicit_num_disks', True)
if not self.settings.explicit_ram:
self.settings.override('ram', Constant.MAKECHECK_DEFAULT_RAM)
Expand Down Expand Up @@ -283,7 +283,7 @@ def __maybe_adjust_num_disks(self):
if self.settings.ssd and new_num_disks:
new_num_disks += 1
if new_num_disks:
self.settings.override('num_disks', new_num_disks)
self.settings.override('num_disks', [new_num_disks])

@property
def _dep_dir(self):
Expand Down Expand Up @@ -423,8 +423,7 @@ def __generate_nodes(self):
node.ram = 2 * 2**10
if self.settings.caasp_deploy_ses or self.settings.explicit_num_disks:
if 'worker' in node_roles or single_node:
for _ in range(self.settings.num_disks):
node.storage_disks.append(Disk(self.settings.disk_size))
self.__append_disks_to_node(node)

if self.settings.version in Constant.CORE_VERSIONS:
if 'suma' in node_roles:
Expand All @@ -433,12 +432,10 @@ def __generate_nodes(self):
if self.settings.cluster_network:
node.cluster_address = '{}{}'.format(self.settings.cluster_network,
200 + node_id)
for _ in range(self.settings.num_disks):
node.storage_disks.append(Disk(self.settings.disk_size))
self.__append_disks_to_node(node)
elif self.settings.explicit_num_disks \
and not node.has_exactly_roles(['master', 'admin']):
for _ in range(self.settings.num_disks):
node.storage_disks.append(Disk(self.settings.disk_size))
self.__append_disks_to_node(node)

if self.has_suma(): # if suma is deployed, we need to add client-tools to all nodes
node.add_custom_repo(ZypperRepo(
Expand Down Expand Up @@ -469,6 +466,14 @@ def __generate_nodes(self):

self.nodes[node.name] = node

def __append_disks_to_node(self, node):
for _i, _n in enumerate(self.settings.num_disks):
for _ in range(_n):
if len(self.settings.disk_size) > _i:
node.storage_disks.append(Disk(self.settings.disk_size[_i]))
else:
node.storate.disks.append(Disk(Constant.DEFAULT_DISK_SIZE))

def __set_version_devel_repos(self):
try:
version = self.settings.version
Expand Down Expand Up @@ -651,7 +656,7 @@ def _generate_vagrantfile(self):
'deepsea_need_stage_4': bool(self.node_counts["nfs"] or self.node_counts["igw"]
or self.node_counts["mds"] or self.node_counts["rgw"]
or self.node_counts["openattic"]),
'total_osds': self.settings.num_disks * self.node_counts["storage"],
'total_osds': sum(self.settings.num_disks) * self.node_counts["storage"],
'encrypted_osds': self.settings.encrypted_osds,
'filestore_osds': self.settings.filestore_osds,
'scc_username': self.settings.scc_username,
Expand Down
8 changes: 4 additions & 4 deletions seslib/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@
'default': Constant.DEVELOPER_TOOLS_REPOS,
},
'disk_size': {
'type': int,
'type': list,
'help': 'Storage disk size in gigabytes',
'default': 8,
'default': [Constant.DEFAULT_DISK_SIZE],
},
'domain': {
'type': str,
Expand Down Expand Up @@ -255,9 +255,9 @@
'default': False,
},
'num_disks': {
'type': int,
'type': list,
'help': 'Number of additional disks in storage nodes',
'default': 2,
'default': [2],
},
'os': {
'type': str,
Expand Down

0 comments on commit fed323a

Please sign in to comment.