Skip to content

Add API design for leak sensor test bits - #2441

Open
fraserg-arista wants to merge 1 commit into
sonic-net:masterfrom
fraserg-arista:leak-test-api
Open

Add API design for leak sensor test bits#2441
fraserg-arista wants to merge 1 commit into
sonic-net:masterfrom
fraserg-arista:leak-test-api

Conversation

@fraserg-arista

@fraserg-arista fraserg-arista commented Jul 2, 2026

Copy link
Copy Markdown

The intention of this API is to allow platforms to expose leak test functionality in their liquid cooling implementation. The state is written to the state DB so that other platform components can distinguish between real and test leaks (e.g. by logging that they would trigger a power cycle, without actually carrying out the action).

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

@fraserg-arista

fraserg-arista commented Jul 2, 2026

Copy link
Copy Markdown
Author

Note: this is written on top of #2413

@judyjoseph @yuazhe

The intent here is that the API is simple enough that it can be implemented in software or hardware, as appropriate for each implementer's leak detection design, so let me know if this is a practical API for you to implement.

@judyjoseph

Copy link
Copy Markdown
Contributor

@fraserg-arista would be great if we have this as a separate PR and get it merged first -- This is useful for community, Let me know your thoughts

@judyjoseph

Copy link
Copy Markdown
Contributor

@chinmoy-nexthop f.y.i

@chinmoy-nexthop

Copy link
Copy Markdown
Contributor

@chinmoy-nexthop f.y.i

Thank you Judy. will take a look.

Comment thread doc/bmc/sonicBMC/pmon-bmc-design.md Outdated

The get_leak_severity() API call has to determine whether any condition indicates a severe leak detected from a leak sensor.This decision could be based on:

When the test bit is enabled, the effective leak state for that sensor is forced to `True` even if the hardware leak input is clear. This affects only leak presence. The physical health returned by `is_leak_sensor_ok()` is unchanged, and `get_leak_severity()` continues to return the platform-defined severity for a leak on that sensor. The test bit is intended for validation and is cleared by default at boot.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

a privileged caller that enables a test leak may be able to trigger the same destructive path as a real leak. yes, we talked about distinction between test leaks from real leaks, but I do not see that reflect in the design.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah, I think you're right here: the fact of this being a test is passed through to thermalctld but it only calculates the overall state of the system for bmcctld to act on, but bmcctld doesn't know that this is a test so it will apply the system policy.

Comment thread doc/bmc/sonicBMC/pmon-bmc-design.md Outdated

The get_leak_severity() API call has to determine whether any condition indicates a severe leak detected from a leak sensor.This decision could be based on:

When the test bit is enabled, the effective leak state for that sensor is forced to `True` even if the hardware leak input is clear. This affects only leak presence. The physical health returned by `is_leak_sensor_ok()` is unchanged, and `get_leak_severity()` continues to return the platform-defined severity for a leak on that sensor. The test bit is intended for validation and is cleared by default at boot.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i mean , the documented defaults are system_leak_policy=enabled and system_critical_leak_action=power_off here i see.

Comment thread doc/bmc/leakage_detection_hld.md Outdated
3. Aggregate per-sensor results into a system leak severity.
4. Expose per-sensor and system leak status through Redis DB for BMC policy enforcement and CLI.
5. Avoid additional PMON overhead on platforms that are not liquid cooled.
6. Support a per-sensor test API that can force a leak indication without requiring physical liquid in the chassis.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the test bit intent is good, but we need to add the the design of “test vs real leak” with explicit flow diagram and boundaries . can you please add.

Comment thread doc/bmc/leakage_detection_hld.md Outdated
Comment on lines +51 to +52
| `set_test_leak(enable)` | Enables or disables a per-sensor test bit that forces the sensor to report a leak |
| `is_test_leak_enabled()` | Returns whether the per-sensor forced-leak test bit is enabled |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is there a way to disable these two APIs in production? Since they appear to be intended only for testing, we may not need them in production. Leaving them enabled could introduce a potential misuse risk.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

An interesting question! Do you know if we have any models in Sonic for this kind of behaviour? (e.g. something that needs a configuration setting to enable a test/debug mode)

Comment thread doc/bmc/leakage_detection_hld.md Outdated

- `syslog_only`
- `graceful_shutdown`
- `power_off`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it make sense to limit the graceful_shutdown/power-off action to cases where the leak source is a test injection? What do you think?

@chinmoy-nexthop chinmoy-nexthop left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice addition. added few suggestions.

also, please add tests that prove forced test leaks cannot power off the host even when they aggregate to CRITICAL.

Comment thread doc/bmc/sonicBMC/pmon-bmc-design.md Outdated
| get_leak_severity() | Get the per-sensor leak severity as `LeakSeverity.CRITICAL`, `LeakSeverity.MINOR`, or `None` |
| get_leak_profile() | Return the `LeakSensorProfileBase` associated with this leak sensor type |
| set_test_leak(enable) | Enable or disable a per-sensor test bit that forces the sensor to report a leak |
| is_test_leak_enabled() | Return whether the per-sensor forced-leak test bit is enabled |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@fraserg-arista Can we have a separate LeakTest class eg: LeakageSensorTestBase where we can define a set of APIs which every platform owner can implement in their platform modules ? This way we can simulate any of the above platofrm API's in the sonic-mgmt test infra

Comment thread doc/bmc/sonicBMC/pmon-bmc-design.md Outdated
- power_off : Immediately power off Switch-Host via platform API module->set_admin_state(DOWN).
```

* **config liquid-cool leak-test sensor**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@fraserg-arista let me know your thought .. I was thinking we really don't need a config command .. but instead using the platform_modules which each platform owner can implement and use it in the sonic_mgmt leak tests to simulate leaks.

We can discuss ideas in the coming workgroup meeting

The intention of this API is to allow platforms to expose leak test
functionality in their liquid cooling implementation. The state is
written to the state DB so that other platform components can
distinguish between real and test leaks (e.g. by logging that they
would trigger a power cycle, without actually carrying out the action).

Signed-off-by: Fraser Gordon <fraserg@arista.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

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.

4 participants