-
Notifications
You must be signed in to change notification settings - Fork 664
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 CLI for configuring synchronous mode #1094
Conversation
scripts/sonic-sync-mode
Outdated
sudo needed for configuring synchronous mode | ||
swss restart required to apply the configuration | ||
Options to restart swss and apply the configuration: | ||
1. config save |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config save [](start = 7, length = 11)
config save
also has -y
. Do you want using? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added -y
in the comment
scripts/sonic-sync-mode
Outdated
Options to restart swss and apply the configuration: | ||
1. config save | ||
config reload -y | ||
2. systemctl restart swss |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
systemctl restart swss [](start = 7, length = 22)
Do you need config save
before restart? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed, updated the help message to clarify the usage.
scripts/sonic-sync-mode
Outdated
|
||
def main(): | ||
parser=argparse.ArgumentParser(description= | ||
'Configure enable or disable synchronous mode between orchagent and syncd', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Configure enable [](start = 11, length = 16)
Enable #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
scripts/sonic-sync-mode
Outdated
table.set('localhost', fvs) | ||
print('Wrote %s synchronous mode into CONFIG_DB, swss restart required to apply the configuration'%(args.mode)) | ||
else: | ||
print('Invalid argument: expect either enable or disable') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print [](start = 8, length = 5)
print to stderr, and return with non zero error code. #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated as prescribed.
scripts/sonic-sync-mode
Outdated
parser.print_help() | ||
|
||
if __name__ == '__main__': | ||
main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
main [](start = 4, length = 4)
Do you have a plan to integrate into config
CLI? Need a design doc. #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Integrated this into config
CLI.
config/main.py
Outdated
1. Keep and apply configuration after config reload \n | ||
config save -y \n | ||
config reload -y \n | ||
2. Discard configuration after config reload \n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discard configuration after config reload [](start = 15, length = 41)
This line has nothing to do with next line. #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the irrelevant line and only kept the commands to restart swss.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor comment issue remains.
retest this please |
need unit test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add unit test
config/main.py
Outdated
config_db.mod_entry('DEVICE_METADATA' , 'localhost', {"synchronous_mode" : sync_mode}) | ||
click.echo("Wrote %s synchronous mode into CONFIG_DB, swss restart required to apply the configuration" % sync_mode) | ||
else: | ||
click.echo("Error: Invalid argument %s, expect either enable or disable" % sync_mode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
click.fail()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. click does not seem to have a function "fail". Using "BadParameter" instead.
config/main.py
Outdated
config_db = ConfigDBConnector() | ||
config_db.connect() | ||
config_db.mod_entry('DEVICE_METADATA' , 'localhost', {"synchronous_mode" : sync_mode}) | ||
click.echo("Wrote %s synchronous mode into CONFIG_DB, swss restart required to apply the configuration" % sync_mode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please be more specific about the message, "you need config save -y and reload -y"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the options to restart swss in the message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@lguohan Could you please let me know if this looks ok? |
- What I did
Add CLI to configure synchronous mode
config synchronous_mode <enable|disable>
- How I did it
Add a CLI script that writes the configuration of synchronous mode into CONFIG_DB and informs users to restart swss to apply the configuration.
- How to verify it
I verified it by testing locally with a virtual switch.
- Previous command output (if the output of a command-line utility has changed)
N/A
- New command output (if the output of a command-line utility has changed)
Wrote enable/disable synchronous mode into CONFIG_DB, swss restart required to apply the configuration