-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Clock commands management HLD #1219
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
a4968d6
Initial doc for HLD
Meir-renford 428521c
Merge pull request #1 from Meir-renford/master
Meir-renford 8775600
Update clock_managment_hld.md
Meir-renford e4607f9
Update clock_managment_hld.md
Meir-renford d6bd0f1
Update clock_managment_hld.md
Meir-renford 9a38f25
Update clock_managment_hld.md
Meir-renford 8fe9815
Update clock_managment_hld.md
Meir-renford 0217fc0
Update clock_managment_hld.md
Meir-renford 54dd6e6
Update clock_managment_hld.md
Meir-renford 0ab39a3
Update clock_managment_hld.md
Meir-renford 9be491b
Update clock_managment_hld.md
Meir-renford 1f31645
Update clock_managment_hld.md
Meir-renford 387066a
Update clock_managment_hld.md
Meir-renford 1546f86
Update clock_managment_hld.md
Meir-renford 36d83a4
Merge branch 'master' into clock-commands
liat-grozovik 340f463
Merge branch 'master' into clock-commands
liat-grozovik 1f27985
Update clock_managment_hld.md
Meir-renford 5886871
Update clock_managment_hld.md
Meir-renford f082135
Update clock_managment_hld.md
Meir-renford 1db60fd
Merge branch 'clock-commands' of https://github.com/Meir-renford/SONi…
Meir-renford 2c29a42
Merge branch 'master' into clock-commands
yxieca 06b0cb4
Merge branch 'master' into clock-commands
liat-grozovik 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,229 @@ | ||
| # Clock Managment Design # | ||
|
|
||
| ## Table of Content | ||
|
|
||
|
|
||
| * 1. [Table of Content](#TableofContent) | ||
| * 1.1. [Revision](#Revision) | ||
| * 1.2. [Scope](#Scope) | ||
| * 1.3. [Definitions/Abbreviations](#DefinitionsAbbreviations) | ||
| * 1.4. [Overview](#Overview) | ||
| * 1.5. [Requirements](#Requirements) | ||
| * 1.5.1. [Functional requirements](#FunctionalRequirements) | ||
| * 1.5.2. [Configuration and Management Requirements](#ConfigurationManagementRequirements) | ||
| * 2. [Design](#Design) | ||
| * 2.1. [High-Level Design](#High-LevelDesign) | ||
| * 3. [Configuration and management](#Configurationandmanagement) | ||
| * 3.1. [ConfigDB Tables](#ConfigDBTables) | ||
| * 3.2. [CLI/YANG model](#CLIYANGmodel) | ||
| * 3.2.1. [Yang model](#Yangmodel) | ||
| * 3.2.2. [CLI](#Climodel) | ||
| * 4. [Test Plan](#TestPlan) | ||
| * 4.1. [Unit Test cases](#UnitTestcases) | ||
|
|
||
|
|
||
| ### 1.1 <a name='Revision'></a>Revision | ||
|
|
||
| | Rev | Date | Author | Change Description | | ||
| | :---: | :-----: | :--------------: | :----------------: | | ||
| | 0.1 | 01/2023 | Meir Renford | High level Design | | ||
|
|
||
| ### 1.2. <a name='Scope'></a>Scope | ||
|
|
||
| This document will address the high level design for clock commands: | ||
| 1. Set/show date-time command | ||
| 2. Set/show timezone command | ||
|
|
||
|
|
||
| ### 1.3 <a name='DefinitionsAbbreviations'></a>Definitions/Abbreviations | ||
|
|
||
| N/A | ||
|
|
||
| ### 1.4 Overview | ||
|
|
||
| The clock commands allow to set and review the current time parameters of the system - including: time, date and timezone. | ||
|
|
||
| ### 1.5 Requirements | ||
| #### 1.5.1. <a name='FunctionalRequirements'></a>Functional requirements | ||
|
|
||
| 1. Any time/date configuration will change accordingly the system time. | ||
|
|
||
| #### 1.5.2. <a name='ConfigurationManagementRequirements'></a>Configuration and Management Requirements | ||
| The requirements from the module are: | ||
| 1. Set and show the system time and date. | ||
| 2. Set and show the system timezone. | ||
|
|
||
|
|
||
| ## 2 <a name='Design'></a>Design | ||
|
|
||
| ### 2.1 <a name='High-LevelDesign'></a>High-Level Design | ||
|
|
||
| The design of this feature is based on Linux command of <b>timedatectl</b>.<BR> | ||
| (man page for timedatectl: https://man7.org/linux/man-pages/man1/timedatectl.1.html) | ||
|
|
||
| All set operations are based on this command, executing directly in linux upon user CLI execution. | ||
| The time/date/timezone are configured directly to Linux, and is persistent upon any reboot. | ||
|
|
||
| System state of time/date/timezone will appear in 1 line as an output of existing "show clock" command. | ||
|
|
||
| hostcfgd will be the daemon in charge of this configuration management. | ||
|
|
||
| <u>CLI Commands desin:</u><br> | ||
|
|
||
| Set operations will be divided into 2 different commands: | ||
|
|
||
| 1. config clock timezone <timezone> (to set timezone command) | ||
| * will get single input as a string, and validate it is valid as part of ("timedatectl list-timezones" command). | ||
| Validation will be done either by YANG model, or (if not possible) by issueing relevant error to log. | ||
| * Value will be stored in db for future upgrade operations. | ||
| Value is persistent upon reboot. | ||
| * Linux timedatectl with set-timezone flag will be called. | ||
| e.g. timedatectl set-timezone "Asia/Kolkata" | ||
| * <b>In case NTP is enabled -> timezone configuration is allowed and overrides the current time.</b> | ||
| * Date & timezone setting will be reflected of all the services/dockers in the system. | ||
|
|
||
|
|
||
| 2. config clock date <YYYY-MM-DD> <HH:MM:SS> (to set time and date) | ||
| * Command will recieve single string with date-time format <YYYY-MM-DD> <HH:MM:SS> | ||
| * Command does not need to be stored in DB. | ||
| * Linux timedatectl with set-time flag will be called. | ||
| e.g. timedatectl set-time "2012-10-30 18:17:16" | ||
| * <b>In case NTP is enabled -> time/date set is NOT allowed and being blocked</b> | ||
|
|
||
Meir-renford marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Additional show command will be added to display all valid timezones: | ||
|
|
||
| 3. show clock timezones | ||
|
|
||
| * Will display list of all valid timezones to be configured. | ||
| * based on "timedatectl list-timezones" linux command. | ||
|
|
||
|
|
||
| <u>General notes:</u><br> | ||
|
|
||
| * Both set commands will be written directly to Linux (via imedatectl command), and will be activated immediately. | ||
|
|
||
| * In case of any set command (time/date/timezone) a relevant message will be print to syslog. | ||
|
|
||
| * In case of any set command (time/date/timezone) - rsyslog service should be restarted to reflect the time change. | ||
|
|
||
| * Upgrades - timezone configuration is part of DEVICE_METADATA, hence - configuration upgrade will be taken care of as any other sonic configuration. | ||
|
|
||
|
|
||
| ## 3 <a name='Configurationandmanagement'></a>Configuration and management | ||
|
|
||
| ### 3.1 <a name='ConfigDBTables'></a>ConfigDB Tables | ||
|
|
||
| Only timezone configuration will be saved. | ||
| Additional field will be added to DEVICE_METADATA table | ||
|
|
||
| ``` | ||
| DEVICE_METADATA :{ | ||
| "timezone": {{string}} | ||
| } | ||
Meir-renford marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| default value: "Etc/UTC" | ||
Meir-renford marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| ### 3.2 <a name='CLIYANGmodel'></a>CLI/YANG model | ||
|
|
||
| #### 3.2.1. <a name='Yangmodel'></a>Yang model | ||
|
|
||
|
|
||
| Adding to existing Yang model of device_metadata (https://github.com/sonic-net/sonic-buildimage/blob/master/src/sonic-yang-models/yang-models/sonic-device_metadata.yang) | ||
|
|
||
| ``` | ||
| container sonic-device_metadata { | ||
|
|
||
| container DEVICE_METADATA { | ||
|
|
||
| description "DEVICE_METADATA part of config_db.json"; | ||
|
|
||
| container localhost{ | ||
| ... | ||
| leaf timezone { | ||
| type string; | ||
Meir-renford marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| description "System time-zone setting"; | ||
| } | ||
| ``` | ||
|
|
||
| #### 3.2.2. <a name='Climodel'></a>CLI | ||
|
|
||
| ##### Show CLI | ||
|
|
||
| ``` | ||
| root@host:~$ show clock | ||
| Sun 15 Jan 2023 06:12:08 PM IST | ||
|
|
||
| ``` | ||
|
|
||
| ``` | ||
| root@host:~$ show clock timezones | ||
| Africa/Abidjan | ||
| Africa/Accra | ||
| Africa/Addis_Ababa | ||
| Africa/Algiers | ||
| Africa/Asmara | ||
| ... | ||
|
|
||
| ``` | ||
|
|
||
| ##### Config CLI | ||
|
|
||
| ``` | ||
| root@host:~$ config clock timezone "<timezone>" | ||
|
|
||
| ``` | ||
|
|
||
| ``` | ||
| root@host:~$ config clock date <YYYY-MM-DD> <HH:MM:SS> | ||
|
|
||
| ``` | ||
|
|
||
|
|
||
| ## 4 <a name='TestPlan'></a>Test Plan | ||
|
|
||
| ### 4.1 <a name='UnitTestcases'></a>Unit Test cases | ||
Meir-renford marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 1. Good flows:<br> | ||
| a. set timezone - <br> | ||
| output of the set command is empty, and expect to see the new timezone in show command output, and the time is correlated with this timezone.<br><br> | ||
|
|
||
| b. set date & time - <br> | ||
| - output of the set command is empty, and expect to see the new date & time in show command output.<br><br> | ||
|
|
||
| c. check reboot - <br> | ||
| rebooting without config save restores configuration (timezone) to the saved one.<br><br> | ||
|
|
||
| d. check docker restart - <br> | ||
| expect to see the time remains as system time.<br><br> | ||
|
|
||
| e. config load / reload <> - <br> | ||
| expect to see timezone changes upon new configuration.<br><br> | ||
|
|
||
| f. reboot without config save - <br> | ||
| expect rebooting without config save restores configuration (timezone) to the saved one.<br><br> | ||
|
|
||
| g. upgrade with manually timedatectl before upgrade - <br> | ||
| Expect to have configuration timezone (if configuration exist) apply and change the timedatectl.<br><br> | ||
|
|
||
|
|
||
| 2. Bad flows:<br> | ||
| a. set invalid timezone - <br> | ||
| expect for error message for invalid timezone, and timezone shouldn’t change (remains the same in show command output).<br><br> | ||
|
|
||
| b. set empty string - <br> | ||
| expect for error message for empty / incomplete command. Nothing should be changed after it.<br><br> | ||
|
|
||
| c. set invalide date/time format - <br> | ||
| expect for error message for the invalid parameter.<br><br> | ||
|
|
||
| 3. NTP interop<br> | ||
| a. Change time/date, followed by changing NTP - and see time changed.<br> | ||
| b. try to change time/date in case NTP is enabled -> and expect getting a failure.<br> | ||
| c. Change timezone in case NTP is enabled, and expect to succeed and change relevant time.<br> | ||
|
|
||
| 4. Rsyslog:<br> | ||
| a. In case of any set command (time/date/timezone) - verify rsyslog service should be restarted to reflect the time change. | ||
|
|
||
| * Functional tests covering flows above will be part of sonic-mgmt tests suite. | ||
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.