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 CLI for configuring synchronous mode #1094

Merged
merged 4 commits into from
Sep 23, 2020
Merged

Conversation

shi-su
Copy link
Contributor

@shi-su shi-su commented Sep 3, 2020

- 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

@shi-su shi-su requested a review from qiluo-msft September 3, 2020 23:54
sudo needed for configuring synchronous mode
swss restart required to apply the configuration
Options to restart swss and apply the configuration:
1. config save
Copy link
Contributor

@qiluo-msft qiluo-msft Sep 4, 2020

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

Copy link
Contributor Author

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

Options to restart swss and apply the configuration:
1. config save
config reload -y
2. systemctl restart swss
Copy link
Contributor

@qiluo-msft qiluo-msft Sep 4, 2020

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

Copy link
Contributor Author

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.


def main():
parser=argparse.ArgumentParser(description=
'Configure enable or disable synchronous mode between orchagent and syncd',
Copy link
Contributor

@qiluo-msft qiluo-msft Sep 4, 2020

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

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')
Copy link
Contributor

@qiluo-msft qiluo-msft Sep 4, 2020

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated as prescribed.

parser.print_help()

if __name__ == '__main__':
main()
Copy link
Contributor

@qiluo-msft qiluo-msft Sep 4, 2020

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

Copy link
Contributor Author

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.

@shi-su shi-su requested a review from qiluo-msft September 8, 2020 22:25
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
Copy link
Contributor

@qiluo-msft qiluo-msft Sep 9, 2020

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

Copy link
Contributor Author

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.

Copy link
Contributor

@qiluo-msft qiluo-msft left a 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.

@shi-su shi-su requested a review from qiluo-msft September 9, 2020 16:40
qiluo-msft
qiluo-msft previously approved these changes Sep 9, 2020
@shi-su
Copy link
Contributor Author

shi-su commented Sep 10, 2020

retest this please

@lguohan
Copy link
Contributor

lguohan commented Sep 10, 2020

need unit test

Copy link
Contributor

@lguohan lguohan left a 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)
Copy link
Contributor

Choose a reason for hiding this comment

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

click.fail()

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 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)
Copy link
Contributor

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"

Copy link
Contributor Author

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.

Copy link
Contributor

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

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

LGTM

@shi-su
Copy link
Contributor Author

shi-su commented Sep 16, 2020

@lguohan Could you please let me know if this looks ok?

@shi-su shi-su merged commit e26aeed into sonic-net:master Sep 23, 2020
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.

3 participants