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

Commit

Permalink
CORTX-33876: Log device size should be power of 2 with limits (#2151)
Browse files Browse the repository at this point in the history
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 <shreya.karmakar@seagate.com>

Signed-off-by: Shreya Karmakar <shreya.karmakar@seagate.com>
  • Loading branch information
Shreya-18 authored Aug 22, 2022
1 parent 1559de0 commit 5d94737
Showing 1 changed file with 33 additions and 1 deletion.
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.
# 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

0 comments on commit 5d94737

Please sign in to comment.