From cad5bb9cfc7cc4ce2024b7b227affb3c7a717f1f Mon Sep 17 00:00:00 2001 From: Lei YU Date: Tue, 22 Jun 2021 15:30:00 +0800 Subject: 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 Change-Id: I732069fff954a2b8b1de4848115641903a8bc904 --- src/store/plugins/WebSocketPlugin.js | 13 +++++-------- 1 file 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 }) => { -- cgit v1.2.3