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

Commit 3a839d2

Browse files
committed
CORTX-33876: Log device size should be power of 2 with limits
The validation for log device size was missing which resulted in failure of cluster bootstrap. Default size was taken from lsblk if not provided via confstore. Solution: Following motr constraints are considered: - the log device size upper and lower bounds is set to 4GB and 128MB respectively. - The size of the log device is rounded off to the nearest power of 2. Signed-off-by: Shreya Karmakar <[email protected]>
1 parent 2073c28 commit 3a839d2

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

cfgen/cfgen

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import socket
1919
import subprocess
2020
from typing import (Any, Callable, Dict, Iterable, Iterator, List, NamedTuple,
2121
Optional, Set, Type, Tuple)
22-
from math import floor, ceil
22+
from math import floor, ceil, log as lg
2323
from hax.log import create_logger_directory
2424
from hax.types import ObjTMaskMap, QW_F, Fid
2525
from hax.types import ObjT as HaxObjT
@@ -455,6 +455,7 @@ def enrich_cluster_desc(desc: Dict[str, Any], mock_p: bool) -> None:
455455
if not m0d['_log_disks']:
456456
m0d['_log_disks'] = get_disks_ssh(node['hostname'], mock_p,
457457
m0d['io_disks']['log'])
458+
set_log_disks_size(m0d['_log_disks'], host)
458459

459460
if 'profiles' not in desc:
460461
sns_pools = [pool['name'] for pool in desc['pools']
@@ -819,6 +820,34 @@ def fabricate_disks(hostname: str, paths: List[str]) -> List[Disk]:
819820
return [Disk(path=x, size=0, blksize=4096) for x in paths]
820821

821822

823+
def set_log_disks_size(log_disks: List[Disk], host: str) -> None:
824+
"""
825+
Update the log disk size provided by the user/lsblk based on the
826+
motr constraints.
827+
"""
828+
def powOf2(num: int) -> int:
829+
power = int(lg(num, 2))
830+
return int(pow(2, power))
831+
832+
KB = int(1024)
833+
MB = int(KB ** 2)
834+
GB = int(KB ** 3)
835+
# [TODO] Hardcoded constraints based on motr requirements.
836+
upper_bound = 4*GB
837+
lower_bound = 128*MB
838+
839+
# Rounding of log device size to the nearest(lower) power of 2.
840+
for i, disk in enumerate(log_disks):
841+
print(dir(disk))
842+
print(disk.size)
843+
size = powOf2(disk.size)
844+
_assert(size >= lower_bound, f"Node {host}: Log device size "
845+
f"in 'io_disks.log' is below {lower_bound}")
846+
if size > upper_bound:
847+
size = upper_bound
848+
log_disks[i] = disk._replace(size=size)
849+
850+
822851
ObjT = Enum('ObjT', 'root fdmi_flt_grp fdmi_filter'
823852
' node process service sdev' # software subtree
824853
' site rack enclosure controller drive' # hardware subtree

0 commit comments

Comments
 (0)