Skip to content

Conversation

@GauravNagesh
Copy link
Contributor

Description

This PR introduces improvements to the PSU daemon by preventing overwriting of values to Redis database even when no value has changed by introducing LED status change detection.

LED status change detection - Adding a led_status instance variable to store the last recorded led status color and an instance method set_led_status to update and store the led status and return True if status changed else False. This reduces writing this value to PSU_INFO_TABLE every 3 seconds even though there was no change.

Additionally, existing tests were updated to include above change changes.
test_update_led_color Updates

  • Tests LED status change detection
  • Verifies DB writes only on status change
  • Comprehensive coverage of state transitions:
    • First run (OFF) → writes
    • No change (OFF→OFF) → no write
    • Change (OFF→GREEN) → writes
    • No change (GREEN→GREEN) → no write
    • change (GREEN→RED) → write
    • change (RED→GREEN) → write

Motivation and Context

Every 3 seconds the daemon writes led_status fields to Redis even though there isn't much changes during the normal execution. This results in unnecessarily Redis traffic and overwriting values in the database. Instead, we can keep track of this info and update it only when it changes.

Also, adding an instance variable to the PsuStatus class will not be a burden since the value stored will be a class variable predefined here or predefined and fetched here Hence no duplicate memory allocated but rather just be a reference to this class variable which will be stored here.

How Has This Been Tested?

The changes were tested on both virtual and physical platforms.

Additional Information (Optional)

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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.

2 participants