summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei YU <yulei.sh@bytedance.com>2021-06-22 10:30:00 +0300
committerDerick Montague <derick.montague@ibm.com>2021-07-21 21:05:17 +0300
commitcad5bb9cfc7cc4ce2024b7b227affb3c7a717f1f (patch)
tree02c8d1dc64524d53ed9626c4faab429cbdbd6fac
parent06d53863a83c003e7248f5cfc8362765882d19bb (diff)
downloadwebui-vue-cad5bb9cfc7cc4ce2024b7b227affb3c7a717f1f.tar.xz
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
-rw-r--r--src/store/plugins/WebSocketPlugin.js13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/store/plugins/WebSocketPlugin.js b/src/store/plugins/WebSocketPlugin.js
index c9f7a89e..cbdc9329 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 @@ const WebSocketPlugin = (store) => {
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 }) => {