Fix inconsistent power status
The webui was using a websocket to subscribe the events from BMC for
server status and logging.
It uses a debouncer of 2.5 to limit the events, however, it causes the
loss of the events, so the power change status event could be missed by
the webui, causing the `Power` status is not really consistent.
There was an issue in the property change handler as well that it
assumes the `CurrentHostState` is there. However, certain event could be
fired without `CurrentHostState` change, e.g. the "ForceWarmReboot" will
get an host event of `RequestedHostTransition` without
`CurrentHostState`'s change, the code will get an undefined
`CurrentHostState` and the `Power` status becomes undetermined.
Remove the 2.5 debouncer, and only set the power status when
`CurrentHostState` is really received to fix the issue.
Tested: Verify the `Power` status is consistent with the server status.
Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: I732069fff954a2b8b1de4848115641903a8bc904
diff --git a/src/store/plugins/WebSocketPlugin.js b/src/store/plugins/WebSocketPlugin.js
index c9f7a89..cbdc932 100644
--- a/src/store/plugins/WebSocketPlugin.js
+++ b/src/store/plugins/WebSocketPlugin.js
@@ -1,5 +1,3 @@
-import { debounce } from 'lodash';
-
/**
* WebSocketPlugin will allow us to get new data from the server
* without having to poll for changes on the frontend.
@@ -31,21 +29,20 @@
ws.onerror = (event) => {
console.error(event);
};
- ws.onmessage = debounce((event) => {
+ ws.onmessage = (event) => {
const data = JSON.parse(event.data);
const eventInterface = data.interface;
const path = data.path;
if (eventInterface === 'xyz.openbmc_project.State.Host') {
const { properties: { CurrentHostState } = {} } = data;
- store.commit('global/setServerStatus', CurrentHostState);
+ if (CurrentHostState) {
+ store.commit('global/setServerStatus', CurrentHostState);
+ }
} else if (path === '/xyz/openbmc_project/logging') {
store.dispatch('eventLog/getEventLogData');
}
- // 2.5 sec debounce to avoid making multiple consecutive
- // GET requests since log related server messages seem to
- // come in clusters
- }, 2500);
+ };
};
store.subscribe(({ type }) => {