Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of a Monitoring Daemon for storage devices in SONiC switches #433

Merged
merged 31 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
dd83c8f
Initial commit of ssdmond
assrinivasan Oct 12, 2023
276f08e
Added support for dynamic fields. Unified table update function. Adde…
assrinivasan Oct 12, 2023
d2f3d49
Added eMMC checks. Added checks before accessing ssdutil objs. Added …
assrinivasan Oct 13, 2023
4582ffc
Removed references to 'ssd' and its variants and replaced with 'stora…
assrinivasan Oct 20, 2023
d8e3930
Created StorageDevices class for device ratification and object creation
assrinivasan Dec 7, 2023
8ad06d9
Renamed daemon to 'storagemond', changed unit tests to reflect the same
assrinivasan Feb 9, 2024
b95d4e2
Renamed storagemond directory and corresponding change to setup.py
assrinivasan Feb 9, 2024
2a0b6b0
Added support for FS IO RW. Cleaned up bugs. Renamed ssd_base --> sto…
assrinivasan Feb 15, 2024
bf910df
Renamed test dirs, changed import to match platform-common dirname ch…
assrinivasan Feb 17, 2024
08d5ecd
Made core algorithm changes per HLD
assrinivasan May 11, 2024
f647149
Renamed dir per sonic naming convention
assrinivasan May 15, 2024
a555cd4
Removed a rogue debugging statuement
assrinivasan May 15, 2024
898f876
Made changes per review comments
assrinivasan May 22, 2024
6ba0155
Added UTs, increased coverage
assrinivasan May 22, 2024
f62f271
Changed log_info to log_error
assrinivasan May 22, 2024
7118c91
Changed function name to match corr. change in SsdUtil
assrinivasan May 23, 2024
d246ac5
Moved get_dynamic_field() to before timeout
assrinivasan May 23, 2024
335b2c8
Cleaned up signal handling, added more UTs
assrinivasan May 23, 2024
b2ec903
Added another UT
assrinivasan May 23, 2024
b146d72
Fixed a bug that was causing sync-to-disk to fail
assrinivasan May 25, 2024
9a94c07
Fixed an eror with _load_fsio_rw_statedb that would assign None value…
assrinivasan May 27, 2024
959c946
Lowered severity for expected log when storage object isnt instantiated
assrinivasan May 28, 2024
d89a8bd
Fixed potential bug where if dynamic_fields fails before populating s…
assrinivasan May 29, 2024
ccbe350
Fixed indentation error
assrinivasan May 29, 2024
4e2f48d
Removed untracked ycabled files that were committed by mistake
assrinivasan May 29, 2024
7c5c88f
Swapped logger for syslogger per prgeor review
assrinivasan May 29, 2024
7b84cc1
log_error --> log_info per review comment
assrinivasan May 29, 2024
b31f591
Made changes per prgeor review comments
assrinivasan May 30, 2024
c83d024
Made changes per prgeor walkthrough review
assrinivasan May 30, 2024
ea45fae
Test mods corresponding to daemon nunction name mods
assrinivasan May 30, 2024
c36f40d
More Uts to pass coverage
assrinivasan May 30, 2024
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
3 changes: 3 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ parameters:
- name: sensormond
root_dir: sonic-sensormond
python3: true
- name: stormond
root_dir: sonic-stormond
python3: true
- name: artifactBranch
type: string
default: 'refs/heads/master'
Expand Down
2 changes: 2 additions & 0 deletions sonic-stormond/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
addopts = --cov=scripts --cov-report html --cov-report term --cov-report xml --junitxml=test-results.xml -vv
380 changes: 380 additions & 0 deletions sonic-stormond/scripts/stormond

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions sonic-stormond/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[aliases]
test=pytest
42 changes: 42 additions & 0 deletions sonic-stormond/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from setuptools import setup

setup(
name='sonic-stormond',
version='1.0',
description='Storage Device Monitoring Daemon for SONiC',
license='Apache 2.0',
author='SONiC Team',
author_email='linuxnetdev@microsoft.com',
url='https://github.com/sonic-net/sonic-platform-daemons',
maintainer='Ashwin Srinivasan',
maintainer_email='assrinivasan@microsoft.com',
scripts=[
'scripts/stormond',
],
setup_requires=[
'pytest-runner',
'wheel'
],
install_requires=[
'enum34',
'sonic-py-common',
],
tests_require=[
'mock>=2.0.0',
'pytest',
'pytest-cov',
],
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: No Input/Output (Daemon)',
'Intended Audience :: Developers',
'Intended Audience :: Information Technology',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Operating System :: POSIX :: Linux',
'Topic :: System :: Hardware',
],
keywords='sonic SONiC ssd Ssd SSD ssdmond storage stormond storagemond',
test_suite='setup.get_test_suite'
)
Empty file.
63 changes: 63 additions & 0 deletions sonic-stormond/tests/mock_swsscommon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
'''
Mock implementation of swsscommon package for unit testing
'''

from swsssdk import ConfigDBConnector, SonicDBConfig, SonicV2Connector

STATE_DB = ''


class Table:
def __init__(self, db, table_name):
self.table_name = table_name
self.mock_dict = {}
self.mock_keys = ['sda']

def _del(self, key):
del self.mock_dict[key]
pass

def set(self, key, fvs):
self.mock_dict[key] = fvs.fv_dict
pass

def get(self, key):
if key in self.mock_dict:
return self.mock_dict[key]
return None

def get_size(self):
return (len(self.mock_dict))

def getKeys(self):
return self.mock_keys

def hgetall(self):
return self.mock_dict


class FieldValuePairs:
fv_dict = {}

def __init__(self, tuple_list):
if isinstance(tuple_list, list) and isinstance(tuple_list[0], tuple):
self.fv_dict = dict(tuple_list)

def __setitem__(self, key, kv_tuple):
self.fv_dict[kv_tuple[0]] = kv_tuple[1]

def __getitem__(self, key):
return self.fv_dict[key]

def __eq__(self, other):
if not isinstance(other, FieldValuePairs):
# don't attempt to compare against unrelated types
return NotImplemented

return self.fv_dict == other.fv_dict

def __repr__(self):
return repr(self.fv_dict)

def __str__(self):
return repr(self.fv_dict)
6 changes: 6 additions & 0 deletions sonic-stormond/tests/mocked_libs/sonic_platform/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""
Mock implementation of sonic_platform package for unit testing
"""

from . import pcie

13 changes: 13 additions & 0 deletions sonic-stormond/tests/mocked_libs/sonic_platform/pcie.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""
Mock implementation of sonic_platform package for unit testing
"""

from sonic_platform_base.pcie_base import PcieBase


class Pcie(PcieBase):
def __init__(self):
self.platform_pcieutil = "/tmp/Pcie"

def __str__(self):
return self.platform_pcieutil
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#
# storage_base.py
#
# Base class for implementing common SSD health features
#


class StorageBase(object):
"""
Base class for interfacing with a SSD
"""
def __init__(self, diskdev):
"""
Constructor

Args:
diskdev: Linux device name to get parameters for
"""
pass

def get_health(self):
"""
Retrieves current disk health in percentages

Returns:
A float number of current ssd health
e.g. 83.5
"""
raise NotImplementedError

def get_temperature(self):
"""
Retrieves current disk temperature in Celsius

Returns:
A float number of current temperature in Celsius
e.g. 40.1
"""
raise NotImplementedError

def get_model(self):
"""
Retrieves model for the given disk device

Returns:
A string holding disk model as provided by the manufacturer
"""
raise NotImplementedError

def get_firmware(self):
"""
Retrieves firmware version for the given disk device

Returns:
A string holding disk firmware version as provided by the manufacturer
"""
raise NotImplementedError

def get_serial(self):
"""
Retrieves serial number for the given disk device

Returns:
A string holding disk serial number as provided by the manufacturer
"""
raise NotImplementedError

def get_vendor_output(self):
"""
Retrieves vendor specific data for the given disk device

Returns:
A string holding some vendor specific disk information
"""
raise NotImplementedError

def get_disk_io_reads(self):
"""
Retrieves the total number of Input/Output (I/O) reads done on a storage disk

Returns:
An integer value of the total number of I/O reads
"""
raise NotImplementedError

def get_disk_io_writes(self):
"""
Retrieves the total number of Input/Output (I/O) writes done on a storage disk

Returns:
An integer value of the total number of I/O writes
"""
raise NotImplementedError

def get_reserved_blocks(self):
"""
Retrieves the total number of reserved blocks in an storage disk

Returns:
An integer value of the total number of reserved blocks
"""
raise NotImplementedError
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

BLKDEV_BASE_PATH = ''

class StorageDevices:
def __init__(self):
self.devices = {'sda' : None}

def _get_storage_devices(self):
pass

def _storage_device_object_factory(self, key):
pass
5 changes: 5 additions & 0 deletions sonic-stormond/tests/mocked_libs/swsscommon/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'''
Mock implementation of swsscommon package for unit testing
'''

from . import swsscommon
66 changes: 66 additions & 0 deletions sonic-stormond/tests/mocked_libs/swsscommon/swsscommon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
'''
Mock implementation of swsscommon package for unit testing
'''

STATE_DB = ''


class Table:
def __init__(self, db, table_name):
self.table_name = table_name
self.mock_dict = {}

def _del(self, key):
del self.mock_dict[key]
pass

def set(self, key, fvs):
self.mock_dict[key] = fvs.fv_dict
pass

def get(self, key):
if key in self.mock_dict:
return self.mock_dict[key]
return None

def get_size(self):
return (len(self.mock_dict))

def getKeys(self):
return list(self.mock_dict.keys())


class FieldValuePairs:
fv_dict = {}

def __init__(self, tuple_list):
if isinstance(tuple_list, list) and isinstance(tuple_list[0], tuple):
self.fv_dict = dict(tuple_list)

def __setitem__(self, key, kv_tuple):
self.fv_dict[kv_tuple[0]] = kv_tuple[1]

def __getitem__(self, key):
return self.fv_dict[key]

def __eq__(self, other):
if not isinstance(other, FieldValuePairs):
# don't attempt to compare against unrelated types
return NotImplemented

return self.fv_dict == other.fv_dict

def __repr__(self):
return repr(self.fv_dict)

def __str__(self):
return repr(self.fv_dict)

class ConfigDBConnector:
pass

class SonicDBConfig:
pass

class SonicV2Connector:
pass
Loading
Loading