-
Notifications
You must be signed in to change notification settings - Fork 134
Module graceful shutdown support #255
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
Open
rameshraghupathy
wants to merge
114
commits into
sonic-net:master
Choose a base branch
from
rameshraghupathy:graceful-shutdown
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
114 commits
Select commit
Hold shift + click to select a range
4e3a096
Did the instrumentation for gnoi-reboot.service
rameshraghupathy 4a7e6bf
Modified based on the Redis based IPC
rameshraghupathy c2f9cb8
Modified based on the Redis based IPC
rameshraghupathy db7848f
made check_platform.sh executable
rameshraghupathy f946e72
Did some cleanup
rameshraghupathy 4434463
Draft version. Need to test again
rameshraghupathy 91897ed
Fixing test failure
rameshraghupathy 118a27a
Working on coverage
rameshraghupathy 1654d44
Working on coverage
rameshraghupathy b1ca2a3
Merge branch 'sonic-net:master' into graceful-shutdown
rameshraghupathy f6936e5
refactored based on the revised HLD
rameshraghupathy 4b709ea
refactored based on the revised HLD
rameshraghupathy d510290
Fixing ut
rameshraghupathy dfa9761
Fixing ut
rameshraghupathy 380b5f9
Improving coverage
rameshraghupathy 62450d6
Refactored for graceful shutdown
rameshraghupathy a7f1a39
Refactored for graceful shutdown
rameshraghupathy f45358a
Fixing ut
rameshraghupathy 14f20e6
Fixing ut
rameshraghupathy 8d647fa
Fixing ut
rameshraghupathy e2c2a71
Fixing ut
rameshraghupathy ada6883
Fixing ut
rameshraghupathy ca6d463
Fixing ut
rameshraghupathy e2bbe5f
Fixing ut
rameshraghupathy 28bc69b
Fixing ut
rameshraghupathy 29183bd
Fixing ut
rameshraghupathy e228ffb
workign on coverage
rameshraghupathy 37d73ce
workign on coverage
rameshraghupathy 601cb90
workign on coverage
rameshraghupathy dfda223
workign on coverage
rameshraghupathy fb51c33
Refactored for graceful shutdown, fixing UT - Final round of tweaks
rameshraghupathy 4650d23
Refactored for graceful shutdown, fixing UT - Final round of tweaks
rameshraghupathy dece2a0
Refactored for graceful shutdown, fixing UT - Final round of tweaks
rameshraghupathy 6a8524f
Refactored for graceful shutdown, fixing UT - Final round of tweaks
rameshraghupathy a381400
Refactored for graceful shutdown, fixing UT - Final round of tweaks
rameshraghupathy da39422
Refactored for graceful shutdown, fixing UT - Final round of tweaks
rameshraghupathy d5ab77b
Refactored for graceful shutdown, fixing UT - Final round of tweaks
rameshraghupathy 78de30a
Refactored for graceful shutdown, fixing UT - Final round of tweaks
rameshraghupathy 39db631
Refactored for graceful shutdown, fixing UT - Final round of tweaks
rameshraghupathy ee497b9
Refactored for graceful shutdown, fixing UT - Final round of tweaks
rameshraghupathy e5558b6
Refactored for graceful shutdown, fixing UT - Final round of tweaks
rameshraghupathy 05571bb
Refactored for graceful shutdown, fixing UT - Final round of tweaks
rameshraghupathy 7285eda
Refactored for graceful shutdown, fixing UT - Final round of tweaks
rameshraghupathy 2009207
Refactored for graceful shutdown, fixing UT - Final round of tweaks
rameshraghupathy 2470888
Addressed copilot PR comments
rameshraghupathy c62e79f
Made the timeout logic common
rameshraghupathy 2106099
working on coverage
rameshraghupathy ffe85ec
working on coverage
rameshraghupathy 22654c8
working on coverage
rameshraghupathy cac4b67
Addressed PR comments
rameshraghupathy 6d46f60
Addressed review comments related to refactoring
rameshraghupathy 4b092dc
Fixing test failures
rameshraghupathy b0bfd18
Fixing test failures
rameshraghupathy aeac810
Addressed review comments related to refactoring
rameshraghupathy 5c98c46
Addressing review comments
rameshraghupathy 8d829cc
Addressing review comments
rameshraghupathy 942874c
Addressing review comments
rameshraghupathy d1533a8
Addressing review comments
rameshraghupathy 8454a37
Addressing review comments
rameshraghupathy 7e3bf57
Addressing review comments
rameshraghupathy 3c93891
Addressing review comments
rameshraghupathy b1f6139
Update scripts/wait-for-sonic-core.sh
rameshraghupathy 6a76f95
Update scripts/wait-for-sonic-core.sh
rameshraghupathy 6005650
Merge branch 'sonic-net:master' into graceful-shutdown
rameshraghupathy 39c5889
Aligning with the new changes in module_base.py PR:#608
rameshraghupathy 4e46ef1
Fixing imports in test
rameshraghupathy 8fa0d79
Fixing test issue
rameshraghupathy dd66d4c
Cleaned up the _handle_successful_reboot function, as the current imp…
rameshraghupathy 74dfe3d
Increasing coverage
rameshraghupathy aa03811
Increasing coverage
rameshraghupathy e379e9e
Doing UT
rameshraghupathy e5a564e
Tested version with the recent module_base changes
rameshraghupathy 693f3a5
Fixed test issue
rameshraghupathy 7b658d2
Fixed test issue
rameshraghupathy ddff999
Fixed test issue
rameshraghupathy 68ce97a
Update scripts/gnoi_shutdown_daemon.py
rameshraghupathy ba36f56
Update scripts/gnoi_shutdown_daemon.py
rameshraghupathy 96f8d99
Update scripts/gnoi_shutdown_daemon.py
rameshraghupathy 4bd5631
Update scripts/gnoi_shutdown_daemon.py
rameshraghupathy a04ccc7
Update scripts/gnoi_shutdown_daemon.py
rameshraghupathy 3a22b62
Update setup.py
rameshraghupathy 22e5684
Update scripts/gnoi_shutdown_daemon.py
rameshraghupathy 6660cc8
Update scripts/gnoi_shutdown_daemon.py
rameshraghupathy 0ef829c
Merge branch 'sonic-net:master' into graceful-shutdown
rameshraghupathy 83ca4a1
Addressed review comments
rameshraghupathy 8da027b
Aligning tests with ddressed review comments
rameshraghupathy e326d70
Fixing a syntax issue
rameshraghupathy 42d3d49
Fixing tests and coverage
rameshraghupathy dc9ad31
Fixing tests and coverage
rameshraghupathy 74125be
Fixing tests and coverage
rameshraghupathy 0f50662
testing the import approach in ut
rameshraghupathy 50fe6ea
added tests
rameshraghupathy 8d2b58f
fixing test issue
rameshraghupathy 8a3bfa3
Update scripts/wait-for-sonic-core.sh
rameshraghupathy 755c8b9
Update scripts/wait-for-sonic-core.sh
rameshraghupathy 910f19d
Update setup.py
rameshraghupathy e146d52
addressed some cosmetic changes suggested by copilot
rameshraghupathy a8567b8
improving coverage
rameshraghupathy 8dbad2e
improving coverage
rameshraghupathy 5e6ccbb
improving coverage
rameshraghupathy 6ab850d
triggering a run
rameshraghupathy f438f3d
triggering a run
rameshraghupathy a20a9f4
triggering a run
rameshraghupathy 5e52daa
cleaning up
rameshraghupathy c6013f3
adding one more test
rameshraghupathy 59521cf
adding one more test
rameshraghupathy d25029a
Update scripts/gnoi_shutdown_daemon.py
rameshraghupathy 0410028
Update scripts/gnoi_shutdown_daemon.py
rameshraghupathy e6c71c4
Update scripts/check_platform.py
rameshraghupathy 7f86b98
addressed review comments
rameshraghupathy 183c337
Fix test failures - add returncode mocking and fix exception test
rameshraghupathy 6ff92ad
addressed review comments
rameshraghupathy fd0037b
added gnoi_shutdown_daemon.py to setup
rameshraghupathy 565294c
Addressed review comments
rameshraghupathy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| [Unit] | ||
| Description=SmartSwitch DPU gNOI Reboot Daemon | ||
| After=rc-local.service | ||
|
|
||
| [Service] | ||
| Type=simple | ||
| ExecStart=/usr/bin/env python3 /usr/local/bin/gnoi-reboot-daemon | ||
| Restart=always | ||
| RestartSec=5 | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| #!/usr/bin/env python3 | ||
| # | ||
| # gnoi-reboot-daemon | ||
| # | ||
| # This daemon facilitates gNOI-based reboot operations for DPU subcomponents within the SONiC platform. | ||
| # It listens for JSON-formatted reboot requests on a named pipe and executes the corresponding gNOI | ||
rameshraghupathy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # Reboot RPCs via the gnmi container. | ||
|
|
||
| try: | ||
| import os | ||
| import json | ||
| import subprocess | ||
| from sonic_py_common import syslogger | ||
|
|
||
| except ImportError as err: | ||
| raise ImportError("%s - required module not found" % str(err)) | ||
|
|
||
| SYSLOG_IDENTIFIER = "gnoi-reboot-daemon" | ||
|
|
||
| FIFO_PATH = "/var/run/gnoi_reboot.pipe" | ||
rameshraghupathy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| # Global logger class instance | ||
| logger = syslogger.SysLogger(SYSLOG_IDENTIFIER) | ||
|
|
||
| def main(): | ||
| # Configure logger to log all messages INFO level and higher | ||
| logger.set_min_log_priority(sonic_logger.DEFAULT_LOG_LEVEL) | ||
|
|
||
| logger.log_info("Starting up...") | ||
|
|
||
| # Ensure the FIFO exists | ||
| if not os.path.exists(FIFO_PATH): | ||
| os.mkfifo(FIFO_PATH) | ||
|
|
||
| # Open the FIFO in read-write mode to prevent blocking | ||
| fifo_fd = os.open(FIFO_PATH, os.O_RDWR) | ||
| with os.fdopen(fifo_fd, 'r') as fifo: | ||
| while True: | ||
| line = fifo.readline() | ||
| if not line: | ||
| continue | ||
|
|
||
| try: | ||
| msg = json.loads(line) | ||
| dpu_ip = msg["dpu_ip"] | ||
| port = msg.get("port", 50052) | ||
vvolam marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| method = msg.get("method", 1) | ||
vvolam marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| message = msg.get("message", "User initiated reboot") | ||
|
|
||
| cmd = [ | ||
| "docker", "exec", "gnmi", "gnoi_client", | ||
| f"-target={dpu_ip}:{port}", | ||
| "-logtostderr", "-notls", | ||
| "-module", "System", | ||
| "-rpc", "Reboot", | ||
| "-jsonin", f'{{"method":{method}, "message":"{message}"}}' | ||
| ] | ||
| result = subprocess.run(cmd, capture_output=True, text=True) | ||
| if result.stdout: | ||
| logger.log_info(f"Command stdout: {result.stdout.strip()}") | ||
| if result.stderr: | ||
| logger.log_warning(f"Command stderr: {result.stderr.strip()}") | ||
| except Exception as e: | ||
| logger.log_error(f"Error processing message: {e}") | ||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.