sonic-utilities icon indicating copy to clipboard operation
sonic-utilities copied to clipboard

[config/show] Configure and retrieve the value of high memory alert and memory threshold of each container.

Open yozhao101 opened this issue 2 years ago • 0 comments

What I did

This PR aims to propose the implementation of show/config commands and users can borrow these two commands to enable/disable high memory alerting and configure memory threshold (maximum memory usage) of each container.

The design proposal is: https://github.com/sonic-net/SONiC/pull/1016

How I did it

I added two functions to implement the show CLI and config CLI respectively such that user can issue the following commands:

show feature memory_threshold show feature memory_threshold <feature_name> config feature memory_threshold <feature_name> <threshold_value

show feature high_memory_alert show feature high_memory_alert <feature_name> config feature high_memory_alert <feature_name> <enabled|disabled>

How to verify it

I verified this change by adding and running the unittest:

    tests/feature_test.py::TestFeature::test_show_feature_status_no_kube_status PASSED [ 33%]
    tests/feature_test.py::TestFeature::test_show_feature_status PASSED      [ 33%]
    tests/feature_test.py::TestFeature::test_show_feature_config PASSED      [ 33%]
    tests/feature_test.py::TestFeature::test_show_feature_status_abbrev_cmd PASSED [ 33%]
    tests/feature_test.py::TestFeature::test_show_bgp_feature_status PASSED  [ 33%]
    tests/feature_test.py::TestFeature::test_show_unknown_feature_status PASSED [ 33%]
    tests/feature_test.py::TestFeature::test_show_feature_autorestart PASSED [ 33%]
    tests/feature_test.py::TestFeature::test_show_feature_high_memory_alert PASSED [ 33%]
    tests/feature_test.py::TestFeature::test_show_feature_memory_threshold PASSED [ 33%]
    tests/feature_test.py::TestFeature::test_fail_autorestart PASSED         [ 33%]
    tests/feature_test.py::TestFeature::test_show_bgp_autorestart_status PASSED [ 33%]
    tests/feature_test.py::TestFeature::test_show_unknown_autorestart_status PASSED [ 33%]
    tests/feature_test.py::TestFeature::test_config_bgp_feature_state PASSED [ 34%]
    tests/feature_test.py::TestFeature::test_config_bgp_feature_state_blocking[disabled-0] PASSED [ 34%]
    tests/feature_test.py::TestFeature::test_config_bgp_feature_state_blocking[failed-1] PASSED [ 34%]
    tests/feature_test.py::TestFeature::test_config_snmp_feature_owner PASSED [ 34%]
    tests/feature_test.py::TestFeature::test_config_unknown_feature_owner PASSED [ 34%]
    tests/feature_test.py::TestFeature::test_config_snmp_feature_fallback PASSED [ 34%]
    tests/feature_test.py::TestFeature::test_config_bgp_autorestart PASSED   [ 34%]
    tests/feature_test.py::TestFeature::test_config_database_feature_state PASSED [ 34%]
    tests/feature_test.py::TestFeature::test_config_database_feature_autorestart PASSED [ 34%]
    tests/feature_test.py::TestFeature::test_config_feature_high_memory_alert_lldp PASSED [ 34%]
    tests/feature_test.py::TestFeature::test_config_feature_memory_threshold_lldp PASSED [ 34%]
    tests/feature_test.py::TestFeature::test_config_unknown_feature PASSED   [ 34%]
    tests/feature_test.py::TestFeatureMultiAsic::test_config_bgp_feature_inconsistent_state PASSED [ 34%]
    tests/feature_test.py::TestFeatureMultiAsic::test_config_bgp_feature_inconsistent_autorestart PASSED [ 34%]
    tests/feature_test.py::TestFeatureMultiAsic::test_config_feature_high_memory_alert_bgp_inconsistent_state PASSED [ 34%]
    tests/feature_test.py::TestFeatureMultiAsic::test_config_feature_memory_threshold_bgp_inconsistent PASSED [ 34%]
    tests/feature_test.py::TestFeatureMultiAsic::test_config_bgp_feature_consistent_state PASSED [ 34%]
    tests/feature_test.py::TestFeatureMultiAsic::test_config_bgp_feature_consistent_autorestart PASSED [ 34%]
    tests/feature_test.py::TestFeatureMultiAsic::test_config_feature_high_memory_alert_bgp_consistent_state PASSED [ 35%]
    tests/feature_test.py::TestFeatureMultiAsic::test_config_feature_memory_threshold_bgp_consistent PASSED [ 35%]

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)

    admin@sonic:~$ show feature high_memory_alert
    feature     HighMemAlert 
    ----------  --------------
    bgp         enabled
    database    enabled
    dhcp_relay  enabled
    lldp        enabled
    pmon        enabled
    radv        enabled
    snmp        enabled
    swss        enabled
    syncd       enabled
    teamd       enabled
    telemetry   enabled

    admin@sonic:~$ show feature high_memory_alert bgp
    feature     HighMemAlert 
    ----------  --------------
    bgp         enabled

    admin@sonic:~$ show feature memory_threshold
    feature      MemThreshold  
    ----------   --------------
    bgp          1073741824    
    database     1073741824    
    dhcp_relay   1073741824    
    lldp         1073741824    
    pmon         1073741824    
    radv         1073741824    
    snmp         1073741824    
    swss         1073741824    
    syncd        1073741824    
    teamd        1073741824    
    telemetry    1073741824 

    admin@sonic:~$ show feature memory_threshold bgp
    feature     MemThreshold
    ----------  --------------
    bgp         1073741824

    admin@sonic:~$ sudo config feature high_memory_alert bgp disabled

    admin@sonic:~$ sudo config feature memory_threshold bgp 1073741824

yozhao101 avatar Jun 30 '22 07:06 yozhao101