Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

CORTX-33876: Log device size should be power of 2 with limits #2151

Merged
merged 1 commit into from
Aug 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion cfgen/cfgen
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ from enum import Enum, auto
from functools import lru_cache, wraps
from typing import (Any, Callable, Dict, Iterable, Iterator, List, NamedTuple,
Optional, Set, Type, Tuple)
from math import floor, ceil
from math import floor, ceil, log as lg
from hax.log import create_logger_directory
from hax.types import ObjTMaskMap, QW_F, Fid
from hax.types import ObjT as HaxObjT
Expand Down Expand Up @@ -463,6 +463,8 @@ def enrich_cluster_desc(desc: Dict[str, Any], mock_p: bool) -> None:
if not m0d['_log_disks']:
m0d['_log_disks'] = get_disks_ssh(node['hostname'], mock_p,
m0d['io_disks']['log'])
if not mock_p:
set_log_disks_size(m0d['_log_disks'], host)

if 'profiles' not in desc:
sns_pools = [pool['name'] for pool in desc['pools']
Expand Down Expand Up @@ -827,6 +829,36 @@ def fabricate_disks(hostname: str, paths: List[str]) -> List[Disk]:
return [Disk(path=x, size=0, blksize=4096) for x in paths]


def set_log_disks_size(log_disks: List[Disk], host: str) -> None:
"""
Update the log disk size provided by the user/lsblk based on the
motr constraints.
"""
def powOf2(num: int) -> int:
power = int(lg(num, 2))
return int(pow(2, power))

KB = int(1024)
MB = int(KB ** 2)
GB = int(KB ** 3)
# [TODO] Hardcoded constraints based on motr requirements.
vaibhavparatwar marked this conversation as resolved.
Show resolved Hide resolved
# Once CORTX-33998 will be completed, these constraints will be
# received from motr APIs.
upper_bound = 4*GB
lower_bound = 128*MB

# Rounding of log device size to the nearest(lower) power of 2.
for i, disk in enumerate(log_disks):
size = powOf2(disk.size)
if size < lower_bound:
raise RuntimeError(
f"Node {host}: Log device size in 'io_disks.log' is below "
f"{lower_bound}.")
if size > upper_bound:
size = upper_bound
log_disks[i] = disk._replace(size=size)


ObjT = Enum('ObjT', 'root fdmi_flt_grp fdmi_filter'
' node process service sdev' # software subtree
' site rack enclosure controller drive' # hardware subtree
Expand Down