-
Notifications
You must be signed in to change notification settings - Fork 667
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
Memory Statistics Config and Show Commands #3575
base: master
Are you sure you want to change the base?
Conversation
/azpw run Azure.sonic-utilities |
/azpw run |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
@qiluo-msft @xincunli-sonic @zbud-msft @FengPan-Frank We have linked the code PRs. Please help review the feature. |
pls fix pretest analysis failure. thanks |
@FengPan-Frank I've resolved it, kindly review. |
seems python test is failed. could you double check? |
@FengPan-Frank there are some test cases failing but those are not related to memory statistics feature. The memory_statistics_test have passed, could you guide what should i do |
|
config/memory_statistics.py
Outdated
def check_memory_statistics_table_existence(memory_statistics_table): | ||
"""Checks whether the 'MEMORY_STATISTICS' table is configured in Config DB.""" | ||
if not memory_statistics_table: | ||
click.echo("Unable to retrieve 'MEMORY_STATISTICS' table from Config DB.", err=True) |
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.
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.
I've added them to syslog as well
config/memory_statistics.py
Outdated
@memory_statistics.command(name="retention-period", short_help="Configure the retention period for Memory Statistics") | ||
@click.argument('retention_period', metavar='<retention_period>', required=True, type=int) | ||
def memory_statistics_retention_period(retention_period): | ||
"""Set the retention period for Memory Statistics""" |
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.
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.
I have now added the explanations as well. KIndly help review again
…t and socket communication Signed-off-by: Arham-Nasir <[email protected]>
@FengPan-Frank @xincunli-sonic I have incorporated the changes you suggested. Kindly help review it |
@FengPan-Frank @xincunli-sonic please review this feature again |
Signed-off-by: Arham-Nasir <[email protected]>
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Arham-Nasir <[email protected]>
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Signed-off-by: Arham-Nasir <[email protected]>
/azp run |
Pull request contains merge conflicts. |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Hi @xincunli-sonic , all suggested changes have been addressed. kindly review and help merge this PR. Thank you! |
Hi @FengPan-Frank , kindly review and help merge this PR. Thank you! |
config/memory_statistics.py
Outdated
syslog.syslog(level, message) | ||
|
||
|
||
def get_db_connection(): |
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.
Seems like every command we are creating a new connection to config db. Perhaps we can create a class variable and create only one connection and reuse?
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.
Hi @zbud-msft ,Thanks for the feedback. I have implemented a Singleton pattern for the database connection, ensuring a single connection is reused across all commands.
Signed-off-by: Arham-Nasir <[email protected]>
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
config/memory_statistics.py
Outdated
level (int): The syslog log level. | ||
""" | ||
syslog.openlog("memory_statistics", syslog.LOG_PID | syslog.LOG_CONS, syslog.LOG_USER) | ||
syslog.syslog(level, 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.
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.
Thank you for the suggestion. I have added a try-finally block to ensure syslog.closelog() is always called after logging the message. Please let me know if there is anything else you’d like me to adjust.
Signed-off-by: Arham-Nasir <[email protected]>
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
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
What I did
Provided support for the configuration and show commands of memory statistics feature.
How I did it
I added a new config file config/memory_statistics.py for the configuration commands of memory statistics feature.
Added a show file show/memory_statistics.py for the show commands of memory statistics feature.
Added a test file tests/memory_statistics_test.py to test the config and show commands of memory statistics feature
How to verify it
Cli support for config and show file is available