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

Add KillProcess gNOI API #213

Merged
merged 26 commits into from
May 31, 2024
Merged

Conversation

isabelmsft
Copy link
Contributor

@isabelmsft isabelmsft commented Apr 8, 2024

Why I did it

Add gNOI API support for stop and restart process.

With this addition, an external client with write permissions can request a process restart or stop. In this first phase, only a subset of services are supported: ['snmp', 'swss', 'dhcp_relay', 'radv', 'restapi', 'lldp', 'sshd']. sonic-host-services dbus rejects any other service management requests.

How I did it

  • Upgrade gNOI version to include KillProcess API
  • Update gNOI client to support KillProcess rpc
  • Implement gNOI API to parse necessary arguments (service name and restart request boolean) from client and invoke dbus API based on client request
  • Support KillProcess and service restart through dbus in sonic-host-services, added in this PR: https://github.com/sonic-net/sonic-host-services/pull/111/files

How to verify it

Unit tests and E2E tests

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@isabelmsft isabelmsft marked this pull request as ready for review April 15, 2024 23:32
@qiluo-msft
Copy link
Collaborator

qiluo-msft commented Apr 16, 2024

Could you add this PR link into HLD PR description? add a code PR table there. #Closed

test/utils.py Outdated

def gnoi_restart_process(valid):
if not valid:
json_data = '{"name": "snmp", "restart": invalid}'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does invalid exist in boolean? or you may want ot use string instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invalid does not exist in boolean, but this is meant to test a failure scenario with invalid option passed. For example, this is the expected outcome when running gnoi_client with an invalid option passed:

root@str-s6100-acs-1:/# gnoi_client -target 127.0.0.1:50052 -logtostderr -insecure -rpc KillProcess -jsonin '{"name": "snmp", "restart": invalid}'    
Kill Process with optional restart
panic: invalid character 'i' looking for beginning of value

goroutine 1 [running]:
main.killProcess(0xb4cbc0, 0xc00027e150, 0xb47980, 0xc00007f240)
        /sonic/src/sonic-gnmi/gnoi_client/gnoi_client.go:120 +0x2b4
main.main()
        /sonic/src/sonic-gnmi/gnoi_client/gnoi_client.go:61 +0x7dd

gnmi_server/gnoi.go Outdated Show resolved Hide resolved
test/utils.py Outdated
@@ -188,6 +188,25 @@ def gnoi_reboot(method, delay, message):
ret, msg = run_cmd(cmd)
return ret, msg

def gnoi_kill_process():
path = os.getcwd()
json_data = '{"name": "snmp"}'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you use fixed data for kill process? I think gnoi_kill_process and gnoi_restart_process should be the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, changed to match gnoi_restart_process

ganglyu
ganglyu previously approved these changes May 22, 2024
Copy link
Contributor

@ganglyu ganglyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

zbud-msft
zbud-msft previously approved these changes May 23, 2024
@qiluo-msft qiluo-msft merged commit 50817e6 into sonic-net:master May 31, 2024
5 checks passed
qiluo-msft pushed a commit to sonic-net/sonic-mgmt that referenced this pull request Jul 15, 2024
### Type of change

- [x] Test case(new/improvement)


### Approach
#### What is the motivation for this PR?
GNOI KillProcess API introduced in this PR: sonic-net/sonic-gnmi#213 requires thorough E2E tests of supported services, and possible failure scenarios
#### How did you do it?
Add E2E tests

#### How did you verify/test it?
Run E2E test on physical DUT

### Documentation
Confirmed passing on latest master: 
---------------------------------------------------------------------------------- live log teardown -----------------------------------------------------------------------------------
22:57:39 gu_utils.rollback                        L0247 INFO   | Commands: config rollback test_setup_checkpoint
22:58:06 conftest.core_dump_and_config_check      L2165 INFO   | Dumping Disk and Memory Space informataion after test on str3-s6100-acs-6
22:58:09 conftest.core_dump_and_config_check      L2169 INFO   | Collecting core dumps after test on str3-s6100-acs-6
22:58:10 conftest.core_dump_and_config_check      L2186 INFO   | Collecting running config after test on str3-s6100-acs-6
22:58:13 conftest.core_dump_and_config_check      L2317 INFO   | Core dump and config check passed for test_gnoi_killprocess.py


=================================================================================== warnings summary ===================================================================================
../../../../usr/local/lib/python3.8/dist-packages/paramiko/transport.py:236
  /usr/local/lib/python3.8/dist-packages/paramiko/transport.py:236: CryptographyDeprecationWarning: Blowfish has been deprecated
    "class": algorithms.Blowfish,

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
------------------------------------------------------------ generated xml file: /var/src/sonic-mgmt-int/tests/logs/tr.xml -------------------------------------------------------------
-------------------------------------------------------------------------------- live log sessionfinish --------------------------------------------------------------------------------
22:58:13 __init__.pytest_terminal_summary         L0067 INFO   | Can not get Allure report URL. Please check logs
====================================================================== 16 passed, 1 warning in 375.00s (0:06:14) =======================================================================
arista-hpandya pushed a commit to arista-hpandya/sonic-mgmt that referenced this pull request Oct 2, 2024
…12478)

### Type of change

- [x] Test case(new/improvement)


### Approach
#### What is the motivation for this PR?
GNOI KillProcess API introduced in this PR: sonic-net/sonic-gnmi#213 requires thorough E2E tests of supported services, and possible failure scenarios
#### How did you do it?
Add E2E tests

#### How did you verify/test it?
Run E2E test on physical DUT

### Documentation
Confirmed passing on latest master: 
---------------------------------------------------------------------------------- live log teardown -----------------------------------------------------------------------------------
22:57:39 gu_utils.rollback                        L0247 INFO   | Commands: config rollback test_setup_checkpoint
22:58:06 conftest.core_dump_and_config_check      L2165 INFO   | Dumping Disk and Memory Space informataion after test on str3-s6100-acs-6
22:58:09 conftest.core_dump_and_config_check      L2169 INFO   | Collecting core dumps after test on str3-s6100-acs-6
22:58:10 conftest.core_dump_and_config_check      L2186 INFO   | Collecting running config after test on str3-s6100-acs-6
22:58:13 conftest.core_dump_and_config_check      L2317 INFO   | Core dump and config check passed for test_gnoi_killprocess.py


=================================================================================== warnings summary ===================================================================================
../../../../usr/local/lib/python3.8/dist-packages/paramiko/transport.py:236
  /usr/local/lib/python3.8/dist-packages/paramiko/transport.py:236: CryptographyDeprecationWarning: Blowfish has been deprecated
    "class": algorithms.Blowfish,

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
------------------------------------------------------------ generated xml file: /var/src/sonic-mgmt-int/tests/logs/tr.xml -------------------------------------------------------------
-------------------------------------------------------------------------------- live log sessionfinish --------------------------------------------------------------------------------
22:58:13 __init__.pytest_terminal_summary         L0067 INFO   | Can not get Allure report URL. Please check logs
====================================================================== 16 passed, 1 warning in 375.00s (0:06:14) =======================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants