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

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

yozhao101
Copy link
Contributor

@yozhao101 yozhao101 commented Jun 30, 2022

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: sonic-net/SONiC#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

…hold/alerting option.

Signed-off-by: Yong Zhao <yozhao@microsoft.com>
memory threshold of each container.

Signed-off-by: Yong Zhao <yozhao@microsoft.com>
Signed-off-by: Yong Zhao <yozhao@microsoft.com>
of sub-commands high memory alert and memory threshold.

Signed-off-by: Yong Zhao <yozhao@microsoft.com>
`high_mem_alert` or `mem_threshold` field did not appear in `FEATURE`
table.

Signed-off-by: Yong Zhao <yozhao@microsoft.com>
Signed-off-by: Yong Zhao <yozhao@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant